var MAX_SHOP = 100;
var currentRoom, packitems, isFromPack = false,
titles = [];
var personList = [];
var noticeList = [];
var isFighting = false;
var isKilling = false;
var isFromItem = false;
var isFromNpc = false;
var isFromPlayer = false;
var isFromMe = false;
var isJiali = false;
var fightType = "";
var unreadMessage = 0;
var skillNpc = "";
var currentSkill = "";
var isFromContent = false;
var back = false;
var defaultExits = ["northwest", "north", "northeast", "west", "look", "east", "southwest", "south", "southeast"];






function stopAnimate(a) {
    $(a).stop(false, true).animate()
}
function showWarnTip(c) {
    console.log(c);
    var b = c.content;
    if ( !! b) {
        var a = $(".tip");
        if (a.length == 0) {
            $("body").append('<div class="tip" onclick=""></div>')
        }
        if (c.subtype == "unconcious" || c.subtype == "sleep") {
            if ($("#overlay").length == 0) {
                $("body").append('<div id="overlay"></div>')
            }
            $("#overlay").height(function() {
                return document.body.scrollHeight
            });
            $("#overlay").width(function() {
                return document.body.scrollWidth
            });
            $("#overlay").fadeTo(200, 0.5);
            $("body").find(".tip").html(b).fadeTo();
            return
        }
        if (c.subtype == "revive" || c.subtype == "awake" || c.subtype == "dead") {
            if ($("#overlay").length != 0) {
                $("#overlay").fadeOut(200)
            }
        }
        $("body").find(".tip").html(b).fadeIn();
        setTimeout(function() {
            $(".tip").fadeOut()
        },
        2000)
    }
}
function showOverlay() {
    $("#overlay").height(function() {
        return document.body.scrollHeight
    });
    $("#overlay").width(function() {
        return document.body.scrollWidth
    });
    $("#overlay").fadeTo(200, 0.5)
}
function hideOverlay() {
    $("#overlay").fadeOut(200)
}
function addPage(a) {
    $(".content").hide();
    $("#content").append(a);
    $(".content").last().show();
    showBackBtn()
}


function addExists(d) {
    var f = d.exits;
    if ( !! f) {
        var a = f.split(":");
        a[0].replace("up", "").replace("down", "");
        var b = $("#" + a[0]);
        if (b.length > 0) {
            b.html(a[1]).addClass("active")
        } else {
            var c = $(".content").first();
            var b = c.find(".otherdirects");
            var e = [];
            if (b.length == 0) {
                e.push('<div class="otherdirects"><div class="label">房间内另有出口：</div><ul id="otherDir">');
                e.push('<li id="', a[0], '" onclick="clickDirection(this);" class="other"><span>', a[1], "</span></li>");
                e.push("</ul></div></div>");
                $(e.join("")).insertAfter($(".ditection", c))
            } else {
                e.push('<li id="', a[0], '" onclick="clickDirection(this);" class="other"><span>', a[1], "</span></li>");
                b.find("ul").append(e.join(""))
            }
        }
    }
}






function removeAllExits(){
		
	var exits=[
		"northwest",
		"north",
		"northeast",
		"west",
		"east",
		"southwest",
		"south",
		"southeast",
	
	];
	
	for(var e in exits){
	
		gcr.removeByExitId(exits[e]);
	}
	//包括其他出口
	$(".otherdirects").remove();
	
	
}



function showMessage(d) {
    if ( !! !d) {
        return
    }
    var c = "<li>" + d + "</li>";
    $("#messagelist").append(c);
    var a = $("#messagelist li");
    if (a.length > 300) {
        for (var b = 0; b < (a.length - 300); b++) {
            a[b].remove()
        }
    }
    $("#messageinner").mCustomScrollbar("scrollTo", "bottom")
}



function showMainChatMessage(d) {
    if ( !! !d) {
        return
    }
    var c = "<li>" + d + "</li>";
    $("#chatList").append(c);
   
    var a = $("#chatList li");
    if (a.length > 2) {
        for (var b = 0; b < (a.length - 2); b++) {
            a[b].remove()
        }
    }
    $("#chatList").mCustomScrollbar("scrollTo", "bottom");
}









function addAction(c) {
    if (isFromNpc || isFromItem || isFromPlayer) {
        var b = $(".content").last().find(".actions");
        b = b.length == 0 ? $(".content").last().find("#npc_list") : b;
        var d = b.find('li[data-command="' + c.command + '"]');
        if (d.length == 0) {
            if (c.command == "withdraw" || c.command == "deposit" || c.command == "roombid bid") {
                var a = '<li data-id="gold" data-actname="' + c.name + '" data-command="' + c.command + '" onclick="showNumDialog(this);"><span>' + c.name + "</span></li>"
            } else {
                if (c.command == "answer") {
                    var a = '<li data-command="' + c.command + '" onclick="showInputDialog(this);"><span>' + c.name + "</span></li>"
                } else {
                    var a = '<li data-command="' + c.command + '" onclick="doAction2(this);" class="actionitem"><span>' + c.name + "</span></li>"
                }
            }
            b.append(a)
        }
    } else {
        storageAction(c);
        refreshActions()
    }
}
function refreshActions() {
    $(".actionitem").remove();
    if ( !! window.localStorage && !!window.localStorage.getItem("actions") && window.localStorage.getItem("actions").length > 0) {
        var b = window.localStorage.getItem("actions");
        var a = JSON.parse(b);
        var d = [];
        for (var c = 0; c < a.length; c++) {
            if (currentRoom.room_id == a[c].roomId) {
                d.push('<li data-command="', a[c].command, '" onclick="doAction2(this);" class="actionitem"><span>', a[c].name, "</span></li>")
            }
        }
        if (d.length > 0) {
            var e = $("#npc_list").find(".npc-item");
            if (e.length > 0) {
                $(d.join("")).insertBefore(e.first())
            } else {
                $("#npc_list").append(d.join(""))
            }
        }
    }
}
function storageAction(d) {
    if ( !! window.localStorage) {
        if ( !! !window.localStorage.getItem("actions")) {
            window.localStorage.setItem("actions", "")
        }
        d.roomId = currentRoom.room_id;
        var b = window.localStorage.getItem("actions");
        var e = [];
        var a = true;
        if (b.length > 0) {
            e = JSON.parse(b);
            for (var c = 0; c < e.length; c++) {
                if (e[c].roomId == currentRoom.room_id && d.name == e[c].name && d.command == e[c].command) {
                    a = false
                }
            }
        }
        if (a) {
            e.push(d);
            window.localStorage.setItem("actions", JSON.stringify(e))
        }
    }
}
function removeAction(d) {
    if (isFromNpc || isFromItem) {
        var c = $(".content").last().find(".actions");
        c = c.length == 0 ? $(".content").last().find("#npc_list") : c;
        c.find("li").each(function() {
            var e = $(this).find("span").html();
            e = e.replace(/\"/g, "'");
            if (e == d.name) {
                $(this).remove();
                return
            }
        })
    } else {
        if ( !! window.localStorage && window.localStorage.getItem("actions").length > 0) {
            var a = JSON.parse(window.localStorage.getItem("actions"));
            for (var b = 0; b < a.length; b++) {
                if (a[b].name == d.name) {
                    a.splice(b, 1)
                }
            }
            window.localStorage.setItem("actions", JSON.stringify(a))
        }
    }
}
function clearActions() {
    window.localStorage.setItem("actions", "")
}
function showStage() {
    $("#title").html("快速驿站");
    titles.push("快速驿站");
    var d = ["无锡城", "武当山", "北京城", "桃花岛", "成都城", "峨嵋山", "大理城", "青城山", "少室山", "洛阳城", "开封城", "福州城", "终南山", "华山村", "昆明城", "临安城", "山海关", "双旗镇", "苏州城", "新兰州", "扬州城", "云中界"];
    var c = [];
    c.push('<div class="content"><div id="stagebox" style="height:95%;width:100%">');
    c.push('<ul class="stagelist">');
    for (var b = 0; b < d.length; b++) {
        var a = b % 2 == 0 ? "yellowtext": "bluetext";
        c.push('<li class="', a, '" onclick="doAction(this);" data-direct="fumove" data-id="', d[b], '">', d[b], "</li>")
    }
    c.push("</ul></div></div>");
    addPage(c.join(""));
    $("#stagebox").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}





function resetTitles(c) {
    var a = titles[0];
    titles = [a];
    titles.push(c);
    var d = $(".content");
    for (var b = 1; b < d.length; b++) {
        d.eq(b).remove()
    }
}
function clickButton(b) {
    $(".statuslist li.active").removeClass("active");
    $(b).addClass("active");
    if ($(b).text() == "常用按钮") {
        loadButtonList();
        return
    }
    var a = $(b).data("command");
    if ( !! a) {
        if (a == "i") {
            send("i");
            send("chawu")
        } else {
            send(a)
        }
    }
}
function clickSkillsButton(b) {
    $(".skillslist li.active").removeClass("active");
    $(b).addClass("active");
    $("#skillsbox ul.active").removeClass("active");
    var a = $(b).data("target");
    $("#skillsbox").find("#" + a).addClass("active")
}
function clickQuestButton(b) {
    $(".questlist li.active").removeClass("active");
    $(b).addClass("active");
    var a = $(b).data("command");
    send(a)
}
function clickInviteButton(b) {
    if ($(b).parent(".invitecontent").length > 0) {
        $(".invitecontent li").removeAttr("style");
        $(b).attr("style", "background:#5B3416");
        var a = $(b).attr("data-uid");
        $(".dialog-buttons a:first").attr("data-command", "team invite " + a)
    }
    $(b).addClass("active")
}
function chuwuAction(h) {
    var b = $("#amount").html();
    b = parseInt(b, 10);
    var g = $(h).data("direct");
    if ( !! g && b > 0) {
        var f = $(h).data("id");
        if (g == "get") {
            send(g + " " + f)
        } else {
            send(g + " " + b + " " + f)
        }
    }
    var e = $(".content").find("#amount");
    var c = e.html();
    e.html("0");
    var a = $(".numbers").find("#maxNumber").val();
    var d = parseInt(a, 10) - parseInt(c, 10);
    $(".numbers").find("#maxNumber").val(d)
}
function doNumAction(d) {
    var a = $("#amount", "#dialog").val();
    var c = $(d).data("direct");
    if (c == "jiali" || c == "roombid bid") {
        send(c + " " + a);
        closeDialog();
        return
    }
    if (a > 0) {
        var a = $("#amount").val();
        a = parseInt(a, 10);
        if ( !! c && a > 0) {
            var b = $(d).data("id");
            send(c + " " + a + " " + b)
        }
        closeDialog();
        if (c == "quwu") {
            setTimeout(function() {
                $(".statuslist li.active").trigger("click")
            },
            500)
        }
    }
}
function loadPack(f) {
    if ( !! !f.inventory) {
        return
    }
    f = f.inventory;
    packitems = f.items;
    var e = [];
    e.push('<div class="packcontent">');
    e.push("<div>", f.desc, "</div>");
    e.push('<ul class="packlist">');
    if ( !! f.items && f.items.length > 0) {
        for (var d = 0; d < f.items.length; d++) {
            var b = f.items[d];
            if ( !! b) {
                var c = !!b.amount ? b.amount: 1;
                e.push('<li id="', b.id, '" data-status="', a, '" onclick="clickPackItem(this);">');
                var a = !!b.status ? b.status: "";
                if (a == "wielded" || a == "worn") {
                    e.push('<span class="diamond"></span>')
                }
                e.push("<span>", b.name, "(", c, ")</span>");
                if (a == "weapon" || a == "armor") {
                    e.push('<span class="minibtn" data-id="', b.id, '" onclick="wield(this);">装备</span>')
                }
                e.push("</li>")
            }
        }
    } else {
        e.push("<li>你的背包暂无东西</li>")
    }
    e.push("</ul></div>");
    $("#statusbox #statusboxcontent").html(e.join(""));
    $("#statusbox").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}


function loadChawu(e) {
    if ( !! !e.chawu) {
        return
    }
    e = e.chawu;
    chawuitems = e.items;
    var d = [];
    d.push('<div class="packcontent">');
    d.push("<div>", e.desc, "</div>");
    d.push('<ul class="packlist">');
    if ( !! e.items && e.items.length > 0) {
        for (var c = 0; c < e.items.length; c++) {
            var a = e.items[c];
            if ( !! a) {
                var b = !!a.amount ? a.amount: 1;
                d.push('<li data-id="', a.id, '" data-command="quwu" data-actname="取出" data-amount="', b, '" onclick="showNumDialog(this);"><span>', a.name, "</span>(", b, ")</li>")
            }
        }
    } else {
        d.push("<li>你的储物袋暂无东西</li>")
    }
    d.push("</ul></div>");
    $("#statusbox #statusboxcontent").append(d.join(""))
}
function loadTitles(d) {
    $("#title").html("称号列表");
    titles.push(title);
    var c = [];
    c.push('<div class="content" id="titlelist">');
    c.push('<div class="currenttitle">当前称号：', d.current, "</div>");
    d = d.title;
    for (var b = 0; b < d.length; b++) {
        c.push('<ul class="titles"><li>', d[b].title, '</li><div data-id="', d[b].id, '" data-direct="title set" class="titlebtn" onclick="changeTitle(this)">更换</div>');
        var a = d[b].desc.replace("|", "</br>");
        c.push("<li>", a, "</li></ul>")
    }
    c.push("</div>");
    addPage(c.join(""));
    $("#titlelist").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}
function showNumDialog(d) {
    var g = $(d);
    var c = g.data("amount");
    if (typeof(c) == "undefined") {
        c = 99999
    }
    var a = g.data("id");
    var b = g.data("command");
    var i = g.data("actname");
    var h = [];
    h.push('<div class="numberbox" style="height: 20%;margin: auto;padding-top: 20%;">');
    h.push('<div class="numbers">');
    h.push('<span class="reduce" onclick="reduceItem();">-</span><input type="tel" min="0" max="', c, '" onchange="intMax(this)" class="number" id="amount" value="0"/><span class="plus" onclick="plusItem();">+</span></div>');
    h.push('<div class="max" onclick="maxItem();">MAX</div>');
    h.push("</div>");
    var e = $("#dialog");
    if (b == "quwu" || b == "jiali" || b == "withdraw" || b == "deposit" || b == "roombid bid") {
        e.find(".dialog-title").html(g.html())
    } else {
        e.find(".dialog-title").html($("#title").html())
    }
    e.find(".dialog-content").html(h.join(""));
    var f = [];
    f.push('<div class="dialogbtn"><a data-direct="', b, '" data-id="', a, '" onclick="doNumAction(this);">', i, "</a></div>");
    f.push('<div class="dialogbtn"><a onclick="closeDialog();">取消</a></div>');
    e.find(".dialog-buttons").html(f.join(""));
    e.show()
}
function showInputDialog(g) {
    var e = $(g);
    var f = e.data("command");
    var d = e.data("actname");
    var c = [];
    c.push('<input type="text" class="msginput"/>');
    var a = $("#dialog");
    a.find(".dialog-title").html(e.html());
    a.find(".dialog-content").html(c.join(""));
    var b = [];
    b.push('<div class="dialogbtn"><a data-direct="', f, '" onclick="sendAnswer(this);">', e.html(), "</a></div>");
    b.push('<div class="dialogbtn"><a onclick="closeDialog();">取消</a></div>');
    a.find(".dialog-buttons").html(b.join(""));
    a.show()
}

function loadBasicstatus(f) {
    var n = f.levelup;
    f = f.basicstatus;
    if ( !! f) {
        var c = [];
        var k = 0;
        c.push('<ul class="basicstatuslist">');
        var j = 0;
        for (var g = 0; g < f.length; g++) {
            if (f[g].key == "giftpoint") {
                j = f[g].content
            }
        }
        j = parseInt(j, 10);
        for (var g = 0; g < f.length; g++) {
            var d = f[g].key == "title" ? "": f[g].name;
            var e = k % 2 != 0 ? "yellowtext": "";
            var b = k % 2 != 0 ? "65%": "35%";
            e = k == 0 ? "nameitem": e;
            if (k == 0) {
                c.push('<li class="', e, '" data-key="', f[g].key, '"><span></span><span>', f[g].content, "</span></li>")
            } else {
                if (j > 0 && (f[g].key == "str" || f[g].key == "int" || f[g].key == "con" || f[g].key == "dex")) {
                    switch (f[g].key) {
                    case "str":
                        tltp = "膂力：影响物理精通，招架精通，偏斜精通，以及基础物理伤害量。";
                        break;
                    case "int":
                        tltp = "悟性：影响内力精通，内力防御，恢复效率，少量影响抵抗等级。一些门派武功需要较高悟性。";
                        break;
                    case "con":
                        tltp = "根骨：影响物理减伤，大量抵抗等级，气血量，内力量。";
                        break;
                    case "dex":
                        tltp = "身法：影响闪避精通，偏斜精通，暴击等级。";
                        break
                    }
                    c.push('<li style="width:', b, '", class="', e, '" data-key="', f[g].key, '" id="basic" data-tltp="', tltp, '"><span>【', d, "】</span><span>", f[g].content, '</span><span class="add" data-command="', f[g].key, '" onclick="addBasicstatus(this);"></span></li>')
                } else {
                    if (f[g].key == "level" && n == 1) {
                        c.push('<li style="width:', b, '", class="', e, '" data-key="', f[g].key, '" id="basic"><span>【', d, "】</span><span>", f[g].content, '</span><span class="add" data-command="levelup" onclick="addBasicstatus(this);"></span></li>')
                    } else {
                        c.push('<li style="width:', b, '", class="', e, '" data-key="', f[g].key, '"><span>【', d, "】</span><span>", f[g].content, "</span></li>")
                    }
                }
            }
            k++;
            if (f[g].key == "neili") {
                var l = f[g].content;
                var a = l.indexOf("(+");
                var h = l.lastIndexOf(")");
                var m = l.substring(a + 2, h);
                if (parseInt(m, 10) == 0) {
                    isJiali = false
                } else {
                    isJiali = true
                }
            }
        }
        c.push("</ul>")
    } else {
        c.push("<div>暂无内容</div>")
    }
    c.push('<div class="blank"></div>');
    $("#statusbox #statusboxcontent").html(c.join(""));
    $("#statusboxcontent").mCustomScrollbar({
        axis: "y",
        setWidth: "100%",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}



function loadCombatstatus(c) {
    c = c.combatstatus;
    if ( !! c) {
        var a = [];
        var b = 0;
        a.push('<ul class="basicstatuslist">');
        for (key in c) {
            if (b % 2 != 0) {
                a.push('<li class="yellowtext"><span>【', key, "】</span><span>", c[key], "</span></li>")
            } else {
                a.push("<li><span>【", key, "】</span><span>", c[key], "</span></li>")
            }
            b++
        }
        a.push("</ul>")
    } else {
        a.push("<div>暂无内容</div>")
    }
    a.push('<div class="fightsetting" onclick="showFightSetting();"><span>战斗</br>设置</span></div>');
    a.push('<div class="fightsetting" data-direct="listweapon" onclick="doAction(this);"><span>备用</br>武器</span></div>');
    a.push('<div class="fightsetting" data-command="listscroll" onclick="doAction2(this);"><span>秘籍</br>设置</span></div>');
    $("#statusbox #statusboxcontent").html(a.join(""));
    $("#statusboxcontent").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}


function showPfmCD(a) {
    $(".fightbuttons").find("li").each(function() {
        var b = $(this).data("direct");
        if (a.scd > 0 && !!b) {
            if (b.indexOf(a.name) >= 0) {
                showCDcover(this, a.scd)
            }
        }
        if (a.pcd > 0) {
            var c = $(this).data("index");
            if (c == 2 || c == 5 || c == 8 || c == 3 || c == 6 || c == 9 || c == 4 || c == 7) {
                if ( !! $(this).attr("onclick")) {
                    showCDcover(this, a.pcd)
                }
            }
        }
    })
}
function showCDcover(c, b) {
    if ($(c).next().tagName != "DIV") {
        var a = $(c).position();
        $(c).attr("onclick", "");
        $(c).after('<div class="cdCover"></div>');
        $(c).next().css("left", a.left);
        $(c).next().css("top", a.top);
        $(c).next().css("margin-left", $(c).css("margin-left"));
        $(c).next().css("margin-top", $(c).css("margin-top"));
        $(c).next().width($(c).width());
        $(c).next().height($(c).height());
        $(c).next().animate({
            width: 0
        },
        b * 1000,
        function() {
            $(this).hide();
            $(this).prev().attr("onclick", "doAction(this)")
        })
    }
}
function loadQuests(e) {
    var d = e.master.split("|")[0];
    var c = [];
    c.push('<div class="questleft">今日任务：</div>');
    c.push('<div class="questright">宗师任务(', e.master.split("|")[0], "/100)[", e.master.split("|")[1], "]<br>师门任务(", e.family.split("|")[0], "/100)[", e.family.split("|")[1], "]</div>");
    e = e.quests;
    if ( !! e) {
        for (var b = 0; b < e.length; b++) {
            var a = e[b].msg.replace("|", "<br>");
            c.push('<div class="questname"><span>', e[b].subtype, "</span> <span>", e[b].name, "</span></div>");
            c.push('<div class="questcontent"><span>', a, "</span></div>");
            c.push('<div class="questbutton">');
            if ( !! e[b].isfugoto && e[b].isfugoto == "1") {
                c.push('<span data-command="fugoto ', e[b].taskid, '" onclick="doAction2(this);" class="iconbutton" style="width:40%">传送</span>')
            }
            c.push('<span data-command="giveup ', e[b].taskid, '" onclick="doCloseAction(this);" class="iconbutton" style="width:40%">放弃</span></div>')
        }
    }
    $("#statusbox #statusboxcontent").html(c.join(""));
    $("#statusboxcontent").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}
function loadTeam(d) {
    d = d.team;
    var b = [];
    b.push('<div class="teammsg"></div>');
    if ( !! d) {
        b.push('<table class="teamtable">');
        for (var a = 0; a < 4; a++) {
            if ( !! d[a]) {
                b.push('<tr bgcolor="#332518"><td width="20%" align="center">', d[a].family, "</td>");
                b.push('<td width="20%" align="center">', d[a].level, "级</td>");
                if (d[a].leader == "1") {
                    b.push('<td width="40%" align="center">', d[a].name, "【队长】</td>");
                    var c = d[a].name
                } else {
                    b.push('<td width="40%" align="center">', d[a].name, "</td>")
                }
                b.push('<td width="20%" align="center">暂无操作</td></tr>');
                b.push("<tr><td> </td><td> </td><td> </td><td> </td></tr>")
            } else {
                b.push('<tr bgcolor="#332518"><td> </td><td> </td><td> </td><td> </td></tr>');
                b.push("<tr><td> </td><td> </td><td> </td><td> </td></tr>")
            }
        }
        b.push("</table>")
    }
    b.push('<div class="teambutton"><ul class="actions">');
    b.push('<li onclick="showInviteDialog();" class="longbutton">邀请组队</li>');
    if ( !! d && d.length > 0) {
        b.push('<li data-command="team dismiss" onclick="doCloseAction(this);" class="longbutton">离开队伍</li>')
    }
    b.push("</ul></div>");
    $("#statusbox #statusboxcontent").html(b.join(""));
    if (d.length == 0) {
        $(".teammsg").html("<li>你现在并没有参加任何队伍。</li>")
    } else {
        $(".teammsg").html('<li style="color:#0CF3FF";>' + c + "的队伍</li>")
    }
}
function loadIntroducer(b) {
    var a = [];
    a.push('<div class="introducer"><li class="introducertitle">我的推广成果：</li><li>我已经邀请了', b.intronum, "人进入游戏。</li><li>我已经累计获利", b.earn, "元宝。</li>");
    var c = window.location.href + "enroll?inv=" + b.myid;
    a.push('<li class="introducertitle">我的推广链接：</li><li class="introducerurl" onclick="goCopy(this)">', c, '</li><li>点击以上链接可复制到剪贴板</li><li style="text-align:left;">1.使用你的推广链接或者使用你的邮箱作为邀请人注册的用户将被记录为你的推广成果。</br>2.推广来的用户，只要在游戏中充值，那么其充值额的10%将作为你的获利，直接出现在你的元宝账户内。</br>3.如有疑问请联系官方群的客服。</li></div>');
    $("#statusbox #statusboxcontent").html(a.join(""));
    $(".introducer").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}
function goCopy(b) {
    var a = new Clipboard(b, {
        text: function() {
            return $(b).text()
        }
    });
    a.on("success",
    function(c) {
        alert("您已成功复制推广链接，请使用CTRL+V进行粘贴。")
    });
    a.on("error",
    function(c) {
        alert("复制失败，请重试。。。")
    })
}
function clickSetFightButton(b) {
    var a = $(b).data("command");
    if ( !! a) {
        $(".fightbuttons li.active").removeClass("active");
        $(b).addClass("active");
        send(a)
    }
}
function showSetFightOptions(d, f) {
    var b = [];
    d = f ? d.listmed: d.listpfm;
    $("#setfightbtns").html("");
    if (d.length == 0) {
        $("#fightButtonsDialog").hide();
        return
    }
    var c = $(document).width();
    var e = Math.ceil(c - 60) / 5;
    for (var a = 0; a < d.length; a++) {
        b.push('<span data-name="' + d[a].name + '" data-id="' + d[a].id + '"style="width:' + e + 'px" onclick="selectButton(this);">' + d[a].name + "</span>")
    }
    $("#isMedicine").val(f);
    $("#setfightbtns").append(b.join(""));
    $("#fightButtonsDialog").show()
}
function selectButton(a) {
    $("#setfightbtns span.active").removeClass("active");
    $(a).addClass("active")
}
function selectFightButton() {
    var c = $("#setfightbtns span.active");
    if (c.length == 0) {
        $("#fightButtonsDialog").hide();
        return
    }
    var b = c.data("name");
    var e = c.data("id");
    var a = $(".fightbuttons li.active").data("index");
    var d = $("#isMedicine").val();
    if (d == "true") {
        send("setpfm " + a + " page 1 " + b + " eat " + e + "#medicine")
    } else {
        send("setpfm " + a + " page 1 " + b + " " + e)
    }
    send("listpfmset")
}
function closeDialog() {
    $("#dialog").find(".dialog-content").html("");
    $("#dialog").find(".dialog-buttons").html("");
    $("#dialog").find(".dialog-content").css("background-image", "");
    $("#dialog").hide()
}
function closeDialog1() {
    $(".dialogbox").removeAttr("style");
    $(".dialog-title").removeAttr("style");
    $(".dialog-content").removeAttr("style");
    $("#dialog").find(".dialog-content").html("");
    $("#dialog").find(".dialog-buttons").html("");
    $("#dialog").find(".dialog-content").css("background-image", "");
    $("#dialog").hide()
}
function showConfirmDialog(c) {
    var a = $("#dialog");
    a.find(".dialog-title").html("提示");
    c = c.replace(/\n/g, "<br/>");
    c = c.replace("|", "<br/>");
    a.find(".dialog-content").html('<div class="dialog-message">' + c + "</div>");
    var b = [];
    b.push('<div class="dialogbtn"><a data-command="y" onclick="clickConfirmDialogButton(this);">是</a></div>');
    b.push('<div class="dialogbtn"><a data-command="n" onclick="clickConfirmDialogButton(this);">否</a></div>');
    a.find(".dialog-buttons").html(b.join(""));
    a.show();
    $(".dialog-content").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}

function showInviteMsg(a) {
    showConfirmDialog(a.msg);
    $(".dialog-buttons a:first").attr("data-command", "team accept " + a.fromid);
    $(".dialog-buttons").find("a").eq(1).attr("onclick", "closeDialog()")
}







function loadNowMap(a) {
    showMap("area", a.nowmap)
}
function showMap(b, a) {
    var c = $("#map");
    closeDialog();
    if (b == "world") {
        $(".mapbox").html('<img id="mappic" src="../images/world.png"/>')
    } else {
        if (b == "area") {
            $(".mapbox").html('<img id="mappic" src="../images/' + a + '.png"/>')
        }
    }
    c.show();
    document.getElementById("mappic").onload = function() {
        new RTP.PinchZoom($(".mapbox").find("img"), {
            tapZoomFactor: 4,
            maxZoom: 8
        })
    }
}

function showAlipay() {
    var b = jQuery.cookie("username");
    var a = "http://vipplatform.frogeyes.com.cn/alipay/payInfo?email=" + b;
    window.open(a)
}
function showWechat() {
    var b = jQuery.cookie("username");
    var a = "http://vipplatform.frogeyes.com.cn/wxpay/payInfo?email=" + b;
    window.open(a)
}
function showInviteDialog() {
    var c = $("#dialog");
    $(".dialogbox").attr("style", "height:60%");
    c.find(".dialog-title").html("邀请组队");
    $(".dialog-title").attr("style", "height:10%");
    var d = [];
    d.push('<ul class="invitelist">');
    d.push('<li onclick="clickInviteButton(this);">最近联系人</li>');
    d.push('</ul><div class="invitecontent">');
    var f = window.localStorage.getItem("friends");
    var b = JSON.parse(f);
    for (var a = 0; a < b.length; a++) {
        d.push('<li data-uid="', b[a].id, '" onclick="clickInviteButton(this);">', b[a].name, "</li>")
    }
    d.push("</div>");
    c.find(".dialog-content").html("").append(d.join(""));
    $(".dialog-content").attr("style", "height:75%");
    var e = [];
    e.push('<div class="dialogbtn"><a data-command="team invite" onclick="clickConfirmDialogButton(this);">邀请</a></div>');
    e.push('<div class="dialogbtn"><a onclick="closeDialog1()">关闭</a></div>');
    c.find(".dialog-buttons").html(e.join(""));
    c.show();
    $(".invitelist > li").eq(0).trigger("click")
}
function clickConfirmDialogButton(b) {
    var a = $(b).data("command");
    send(a);
    closeDialog();
    if (a == "y") {
        if ( !! back) {
            $("#back").trigger("click");
            back = false
        }
        if ($(".questleft").length == 1) {
            send("quest")
        }
        if ($("#weapon0").length == 1) {
            send("listweapon");
            send("listweaponset")
        }
    }
}
function shopMapShop(d) {
    $("#title").html("地图商店");
    titles.push(title);
    var c = [];
    c.push('<div class="content">');
    c.push('<div id="maplist"><ul class="maplist">');
    var a = d.items;
    if ( !! a && a.length > 0) {
        for (var b = 0; b < a.length; b++) {
            var e = a[b];
            c.push("<li><span>", e.name, "</span></br><span>价格：", e.price, "</span><span>  已售：", e.saled, "份</span>");
            c.push('<div data-id="', e.id, '" data-direct="buy" onclick="doAction(this)">购买</div></li>')
        }
    }
    c.push("</ul></div>");
    c.push("</div>");
    addPage(c.join(""));
    $("#maplist").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}
// function showShop(d) {
//     var f = titles[titles.length - 1] + "贩卖的物品";
//     $("#title").html(f);
//     titles.push(f);
//     var c = [];
//     c.push('<div class="content">');
//     c.push('<div class="shoptitle"><span>物品列表</span></div>');
//     c.push('<div id="shoplist"><ul class="shoplist">');
//     var a = d.shoplist.items;
//     if ( !! a && a.length > 0) {
//         for (var b = 0; b < a.length; b++) {
//             var e = a[b];
//             c.push('<li data-id="', e.id, '"><span>', e.name, "</span><span>", e.value, "</span>");
//             c.push('<span><span class="shop-plus" onclick="reduceItemsNum(this)"><a>-</a></span><input type="tel" min="0" max="', MAX_SHOP, '" value="0" onchange="intMax(this)" class="shop-num"/><span class="shop-add" onclick="addItemsNum(this);"><a>+</a></span></span>');
//             c.push("</li>")
//         }
//     }
//     c.push("</ul></div>");
//     c.push('<div class="buybutton"><a class="buy-btn" onclick="buyItems();">购买</a></div>');
//     c.push("</div>");
//     addPage(c.join(""));
//     $("#shoplist").mCustomScrollbar({
//         axis: "y",
//         mouseWheel: {
//             enable: true
//         },
//         advanced: {
//             updateOnContentResize: true
//         }
//     })
// }
function addItemsNum(d) {
    var b = $(d).parent();
    var c = $(".shop-num", b).val();
    var a = $(".shop-num", b).attr("max");
    c = parseInt(c, 10) + 1;
    if (a != "undefined" && c >= a) {
        c = a
    }
    if (c > MAX_SHOP) {
        c = MAX_SHOP
    }
    $(".shop-num", b).val(c)
}
function reduceItemsNum(c) {
    var a = $(c).parent();
    var b = $(".shop-num", a).val();
    b = parseInt(b, 10);
    if (b == 0) {
        return
    }
    b = b - 1;
    $(".shop-num", a).val(b)
}
function buyItems() {
    $(".shoplist li").each(function() {
        var b = $(this);
        var c = b.data("id");
        targetEl = b.find(".shop-num");
        var a = targetEl.val();
        a = parseInt(a, 10);
        if ($("#title").text() == "会员商城" && a > 0) {
            command = "shop buy " + a + " " + c;
            send(command);
            targetEl.val("0");
            closeDialog()
        } else {
            if ($("#title").text() == "限时折扣" && a > 0) {
                command = "limitshop buy " + a + " " + c;
                send(command);
                targetEl.val("0");
                closeDialog()
            } else {
                if ($("#title").text() == "门派贡献兑换" || $("#title").text() == "经验商店" || $("#title").text() == "秘籍兑换" || $("#title").text() == "喜鹊羽兑换" && a > 0) {
                    command = "fmshop buy " + a + " " + c;
                    send(command);
                    targetEl.val("0");
                    closeDialog()
                } else {
                    if (a > 0) {
                        command = "buy " + a + " " + c;
                        send(command);
                        targetEl.val("0")
                    }
                }
            }
        }
    })
}


function showSkillDetail(c) {
    $("#title").html("技能详情");
    titles.push(title);
    var b = [];
    b.push('<div class="content">');
    b.push('<div id="skilldetailbox" style="width:100%;height:95%;"><div class="skillsdesc">');
    var e = c.checkskill.split("|");
    for (var a = 0; a < e.length; a++) {
        b.push(e[a] + "</br>")
    }
    b.push("</div>");
    b.push('<div class="npclist"><ul class="actions">');
    if ( !! skillNpc.id) {
        b.push('<li data-command="xue ', skillNpc.id, " about ", c.skillid, '" onclick="doAction2(this);"><span>学习</span></li>');
        b.push('<li data-command="xue ', skillNpc.id, " about 10 ", c.skillid, '" onclick="doAction2(this);"><span class="nowrap">学习</br>十次</span></li>')
    } else {
        if ( !! c.button && c.button.length > 0) {
            for (var a = 0; a < c.button.length; a++) {
                var d = c.button[a];
                b.push('<li data-command="', d.command, '" onclick="doAction2(this);" class="longbutton"><span>', d.name, "</span></li>")
            }
        }
        b.push('<li data-command="fangqi ', c.skillid, '" onclick="doAction2(this);" class="longbutton"><span>放弃</span></li>')
    }
    b.push("</ul>");
    b.push("</div></div>");
    addPage(b.join(""));
    $("#skilldetailbox").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    })
}
function loadMapset(f) {
    var g, h;
    h = f.type;
    switch (f.type) {
    case "listmap":
        $("#title").html("地图设置");
        g = "map set";
        break;
    case "listscroll":
        $("#title").html("秘籍设置");
        g = "setscroll";
        break;
    default:
        return
    }
    titles.push(title);
    var e = [];
    e.push('<div class="content">');
    e.push('<div class="researchbox" style="margin-top: 1em;"><ul class="researchinfo">');
    f = f.items;
    if ( !! f && f.length > 0) {
        for (var d = 0; d < f.length; d++) {
            e.push("<li><span>", f[d].item, "</span>");
            if (g == "setscroll") {
                e.push('<div class="level" data-id="', f[d].id, '" data-direct="setscroll" onclick="doAction(this);">查看全部</div>')
            }
            e.push("</li>");
            e.push('<ul class="researchdetail">');
            for (var b = 0; b < f[d].subitems.length; b++) {
                e.push('<li><span class="mapname">', f[d].subitems[b].name, "</span>");
                e.push('<div class="researchbtn" style="margin-right:2em;" data-id="', f[d].subitems[b].id, '" data-direct="', g, '" data-used=', f[d].subitems[b].used, ' onclick="doAction3(this);">使用</div>');
                e.push("</li>")
            }
            e.push("</ul>")
        }
    }
    e.push("</ul></div></div>");
    addPage(e.join(""));
    $(".researchbox").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    });
    checkMapUsed(h);
    var a = $(".researchdetail");
    var c = $(".researchinfo");
    a.hide();
    a.first().delay(400).slideDown(700);
    a.on("click", "li",
    function() {
        a.siblings().find("li").removeClass("chosen");
        $(this).addClass("chosen")
    });
    c.on("click", "li",
    function() {
        $(this).next(".researchdetail").slideToggle().siblings(".researchdetail").slideUp()
    });
    c.children("li:last-child").on("click",
    function() {
        c.fadeOut().delay(500).fadeIn()
    })
}
function checkMapUsed(a) {
    $(".researchdetail").find(".researchbtn").each(function() {
        if (a == "listmap") {
            if ($(this).attr("data-used") == "1") {
                $(this).hide()
            } else {
                if ($(this).attr("data-used") == "0") {
                    $(this).show()
                }
            }
        } else {
            if (a == "listscroll") {
                if ( !! $(this).data("used")) {
                    $(this).text("取消")
                } else {
                    if (!$(this).data("used")) {
                        $(this).text("使用")
                    }
                }
            }
        }
    })
}
function showResearch(f) {
    $("#title").html(f.name);
    titles.push(title);
    var d = f.id;
    var b = [];
    b.push('<div class="content">');
    var n = f.points.split("|");
    b.push('<div class="researchpoint"><span class="researchspan">当前研究等级', n[0], "/", n[1], '</span><span class="researchspan">剩余研究点：', n[2], "</span>");
    if (f.progress == 0) {
        var o = "width: 100%;border-bottom-left-radius: 3.5em;border-top-left-radius: 3.5em;"
    } else {
        o = "width: " + (100 - f.progress) + "%;"
    }
    b.push('<span>研究进度：</span><span class="researchprogbox"><span class="researchpgbg"></span><span class="researchpgnow" style="', o, '"></span><span class="researchvalue">', f.progress, "%</span></div>");
    b.push('<div class="startresearch" id="research" data-direct="research" data-command="halt" data-id="', d, '" onclick="doAction(this);">开始<br/>研究</div>');
    b.push('<div class="researchbox"><ul class="researchinfo">');
    f = f.researchinfo;
    for (var g = 0; g < f.length; g++) {
        var a = f[g].level.split("|");
        b.push("<li><span>", f[g].name, '</span><div class="level" data-command="researchcancel ', f[g].id, " of ", d, '" onclick="doAction2(this)">', a[0], "/", a[1], " 重置</div></li>");
        b.push('<ul class="researchdetail">');
        for (var e = 0; e < f[g].detail.length; e++) {
            var m = f[g].detail[e].value.split("|");
            var l = "";
            var k = m[0] * 100 / m[1];
            k = k == "NaN" ? 0 : Math.floor(k);
            if (k == 100) {
                l = "green"
            } else {
                if (k >= 50) {
                    l = "orange"
                } else {
                    if (k > 0) {
                        l = "red"
                    }
                }
            }
            b.push('<li><span class="researchlevel" style="color:', l, '">', e + 1, '级</span><div class="valuebox">');
            b.push('<div class="valueprogress" style="width:', k, "%;background:", l, '"></div><div class="valuebg"></div><div class="researchvalue">', m[0], "%/", m[1], "%</div>");
            b.push("</div>");
            if (k == 0 && n[2] != 0) {
                b.push('<div class="researchbtn" data-direct="researchset ', f[g].id, " ", e + 1, " of ", d, '" onclick="doResearch(this);">分配</div>')
            } else {
                if (k < 100 && k > 0) {
                    b.push('<div class="researchbtn" data-direct="researchset ', f[g].id, " ", e + 1, " of ", d, '" onclick="doResearch(this);">补缀</div>')
                }
            }
            b.push("</li>")
        }
        b.push("</ul>")
    }
    b.push("</ul></div>");
    b.push("</div>");
    addPage(b.join(""));
    $(".researchbox").mCustomScrollbar({
        axis: "y",
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    });
    var h = $(".researchdetail");
    var c = $(".researchinfo");
    h.hide();
    h.first().delay(400).slideDown(700);
    h.on("click", "li",
    function() {
        h.siblings().find("li").removeClass("chosen");
        $(this).addClass("chosen")
    });
    c.on("click", "li",
    function() {
        $(this).next(".researchdetail").slideToggle().siblings(".researchdetail").slideUp()
    });
    c.children("li:last-child").on("click",
    function() {
        c.fadeOut().delay(500).fadeIn()
    })
}
function showChat() {
    var a = $("#chatPage");
    if (a.length == 0) {
        var b = [];
        b.push('<div id="chatPage" class="page">');
        b.push('<div class="title" id="nav">');
        b.push('<a class="btn left icon-map" id="nav-leftbtn" style="display: none;"></a>');
        b.push('<span id="title">聊天</span>');
        b.push('<a class="btn right icon-area" id="nav-rightbtn" style="display: none;"></a>');
        b.push('<a class="btn right icon-back" id="chatback" onclick="chatBack();"></a>');
        b.push("</div>");
        b.push('<div id="chatContent">');
        b.push('<div class="content chatContent">');
        b.push('<ul class="chattype">');
        b.push('<li onclick="clickChatButton(this);" data-type="all">全部</li>');
        b.push('<li onclick="clickChatButton(this);" data-type="chat">闲聊</li>');
        b.push('<li onclick="clickChatButton(this);" data-type="music">传闻</li>');
        b.push('<li onclick="clickChatButton(this);" data-type="tell">私聊</li>');
        b.push('<li onclick="clickChatButton(this);" data-type="say">场景</li>');
        b.push('<li onclick="clickChatButton(this);" data-type="family">师门</li>');
        b.push('<li onclick="clickChatButton(this);" data-type="rumor">谣言</li>');
        b.push("</ul>");
        b.push("</div>");
        b.push('<div id="innercontent">');
        b.push('<ul class="chatlist"></ul>');
        b.push("</div>");
        b.push("</div>");
        b.push('<div class="sendbox">');
        b.push('<span class="lookbox" onclick="showEmoteBox();">表情</span><span class="personbox" onclick="chooseFriend();">对象(无)</span>');
        b.push('<span class="inputbox"><input type="text" id="sendmessage"/></span>');
        b.push('<span class="sendbtn"  onclick="sendChatMessage();">发送</span>');
        b.push('<div class="emotebox" id="emotebox">');
        b.push('<div class="emotebtnbox">');
        b.push('<a class="emotebtn" onclick="clearEmote();">清除表情</a><a class="emotebtn" onclick="closeEmote();">关闭</a>');
        b.push("</div>");
        b.push('<div id="semote">');
        b.push(addEmote());
        b.push("</div>");
        b.push("</div>");
        b.push('<div id="friendbox">');
        b.push('<ul id="friendlist"></ul>');
        b.push("</div>");
        b.push("</div>");
        b.push("</div>");
        $("body").append(b.join(""));
        $(".chattype > li").eq(0).trigger("click");
        $(".dialog").hide();
        $("#chatPage").show();
        $("#innercontent").mCustomScrollbar({
            axis: "y",
            mouseWheel: {
                enable: true
            },
            advanced: {
                updateOnContentResize: true
            }
        });
        $("#innercontent").mCustomScrollbar("scrollTo", "bottom");
        $("#semote").mCustomScrollbar({
            axis: "y",
            mouseWheel: {
                enable: true
            },
            advanced: {
                updateOnContentResize: true
            }
        });
        refreshFriend();
        unreadMessage = 0;
        $(".messageNum").html("0").hide()
    }
}
function addEmote() {
    var e = ["back", "welcome", "hammer", "rou", "139", "me", "baixi", "ball", "blood", "miss", "mo", "18mo", "bao", "nali", "dahua", "buyao", "bye3", "cut1", "maimai", "xbc"];
    var b = [];
    var c = $(document).width();
    var d = Math.ceil(c - 60) / 5;
    for (var a = 0; a < e.length; a++) {
        b.push('<span data-emote="' + e[a] + '" style="width:' + d + 'px" onclick="clickEmote(this);">' + e[a] + "</span>")
    }
    return b.join("")
}
function showEmoteBox() {
    var a = $(".chattype .active").data("type");
    if (a == "tell") {
        return
    }
    $("#friendbox").removeClass("active");
    if ($("#emotebox").hasClass("active")) {
        $("#emotebox").removeClass("active")
    } else {
        $("#emotebox").addClass("active")
    }
}
function clickEmote(b) {
    var a = $(b).data("emote");
    $(".sendbox .lookbox").html(a);
    $("#sendmessage").attr("readonly", "readonly").addClass("disabled");
    $("#emotebox").removeClass("active")
}
function clearEmote() {
    $("#emotebox").removeClass("active");
    $("#sendmessage").val("");
    $(".sendbox .lookbox").html("表情");
    $("#sendmessage").removeAttr("readonly").removeClass("disabled")
}
function closeEmote() {
    $("#emotebox").hide()
}
function clearPerson() {
    $(".sendbox .personbox").html("对象(无)").data("uid", "")
}
function sendChatMessage() {
    var a = $(".chattype .active").data("type");
    if (a == "all") {
        a = "chat"
    }
    var d = $(".sendbox .lookbox").html();
    var b = $("#sendmessage").val();
    if (a == "say") {
        var c = $(".sendbox .personbox").data("uid");
        if (d != "表情" && !!!c) {
            send(d)
        } else {
            if (d != "表情" && !!c) {
                send(d + " " + c)
            } else {
                send("say " + b)
            }
        }
    } else {
        if (a == "tell") {
            var c = $(".sendbox .personbox").data("uid");
            if ( !! !c) {
                alert("请选择私聊对象");
                return
            } else {
                send("tell " + c + " " + b)
            }
        } else {
            if (d != "表情") {
                var c = $(".sendbox .personbox").data("uid");
                if ( !! c) {
                    send(a + "* " + d + " " + c)
                } else {
                    send(a + "* " + d)
                }
            } else {
                if ( !! b) {
                    send(a + " " + b)
                }
            }
        }
    }
    clearEmote();
    clearPerson()
}
function showChatMessage(f, i) {
    var c = f.msg;
    if ( !! c) {
        var d = f.fromname;
        var b = "";
        if (f.fromid == "0") {
            b = '<span class="chatperson disabled" data-uid="' + f.fromid + '">' + d + "</span>"
        } else {
            b = '<span class="chatperson" data-uid="' + f.fromid + '">' + d + "</span>"
        }
        c = c.replace(new RegExp(/%fromname%/g), b);
        var j = f.toname;
        var h = '<span class="chatperson" data-uid="' + f.toid + '">' + j + "</span>";
        c = c.replace(new RegExp(/%toname%/g), h);
        var a = '<li class="' + f.subtype + '">' + c + "</li>";
        $("#innercontent .chatlist").append(a);
        if (i) {
            addChatHistory(f);
            if (f.subtype == "say" || f.subtype == "tell" || f.subtype == "chat") {
                var g = c.replace(new RegExp(/%fromname%/g), d);
                g = g.replace(new RegExp(/%toname%/g), j);
                showMessage(g)
            }
            if (f.subtype == "music") {
                gcr.showNotification(c);
                if ($("#chatPage").length == 0) {
                    return
                }
            }
        }
        if ( !! $("#innercontent").length) {
            $("#innercontent").mCustomScrollbar("scrollTo", "bottom")
        }
        var e = $("#chatPage");
        if (e.length == 0) {
            unreadMessage++;
            $(".messageNum").html(unreadMessage).show()
        }
    }
}

function clickChatButton(g) {
    var f = $(g);
    $(".chattype li.active").removeClass("active");
    f.addClass("active");
    var d = f.data("type");
    if (d == "music") {
        $("#innercontent li").hide();
        $(".sendbox").hide();
        return
    } else {
        $(".sendbox").show()
    }
    $("#innercontent li").remove();
    if ( !! window.localStorage && !!window.localStorage.getItem("chathistory") && window.localStorage.getItem("chathistory").length > 0) {
        var e = window.localStorage.getItem("chathistory");
        var a = JSON.parse(e);
        var c = [];
        for (var b = 0; b < a.length; b++) {
            showChatMessage(a[b], false)
        }
    }
    if (d == "all") {
        $("#innercontent li").show()
    } else {
        $("#innercontent li").hide();
        $("#innercontent").find("." + d).show()
    }
}
function addChatHistory(c) {
    if ( !! window.localStorage) {
        if ( !! !window.localStorage.getItem("chathistory")) {
            window.localStorage.setItem("chathistory", "")
        }
        var a = window.localStorage.getItem("chathistory");
        var b = a.length == 0 ? [] : JSON.parse(a);
        b.push(c);
        if (b.length > 40) {
            b.splice(0, 10)
        }
        window.localStorage.setItem("chathistory", JSON.stringify(b))
    }
}
function chatBack() {
    $("#chatPage").remove()
}
function storageFriend(d) {
    if ( !! window.localStorage) {
        if ( !! !window.localStorage.getItem("friends")) {
            window.localStorage.setItem("friends", "")
        }
        var e = window.localStorage.getItem("friends");
        var c = [];
        var a = true;
        if (e.length > 0) {
            c = JSON.parse(e);
            for (var b = 0; b < c.length; b++) {
                if (c[b].id == d.id) {
                    a = false
                }
            }
        }
        if (a && c.length < 20) {
            c.push(d);
            window.localStorage.setItem("friends", JSON.stringify(c))
        }
    }
}
function refreshFriend() {
    $("#friendbox").mCustomScrollbar("destroy");
    $(".frienditem").remove();
    if ( !! window.localStorage && !!window.localStorage.getItem("friends") && window.localStorage.getItem("friends").length > 0) {
        var d = window.localStorage.getItem("friends");
        var c = JSON.parse(d);
        var b = [];
        for (var a = 0; a < c.length; a++) {
            b.push('<li class="frienditem" data-uid="', c[a].id, '" onclick="selectFriend(this);">', c[a].name, "</li>")
        }
        $("#friendlist").html("").append(b.join(""));
        $("#friendbox").mCustomScrollbar({
            axis: "y",
            mouseWheel: {
                enable: true
            },
            advanced: {
                updateOnContentResize: true
            }
        })
    }
}
function chooseFriend() {
    $("#emotebox").removeClass("active");
    var a = $("#friendbox .frienditem");
    if (a.length == 0) {
        $("#friendbox").removeClass("active")
    } else {
        if ($("#friendbox").hasClass("active")) {
            $("#friendbox").removeClass("active")
        } else {
            $("#friendbox").addClass("active")
        }
    }
}
function selectFriend(c) {
    var b = $(c).data("uid");
    var a = $(c).html();
    $(".sendbox .personbox").html(a).data("uid", b);
    $("#friendbox").removeClass("active")
}
function fightBack() {
    $("#fightPage").remove();
    isFighting = false;
    send("look");
    send("checkfight")
}
function showEscape(c) {
    if (c.result == "true") {
        if ( !! c.team) {
            var b = $("#fightContent").find('ul[data-team="' + c.team + '"]');
            var a = b.find('li[data-uid="' + c.id + '"]');
            if (a.length > 0) {
                a.remove()
            } else {
                return
            }
        } else {
            fightBack()
        }
    }
}
function loadFightInfo(f) {
    isFighting = true;
    var o = $("#fightPage");
    if (o.length == 0) {
        var k = new Array;
        var n = new Array;
        for (var g = 0; g < f.startfight.length; g++) {
            if (f.startfight[g].team == f.startfight[0].team) {
                k.push(f.startfight[g])
            } else {
                n.push(f.startfight[g])
            }
        }
        var b = [];
        b.push('<div id="fightPage" class="page">');
        b.push('<div class="title" id="nav">');
        b.push('<span id="title">比试</span>');
        b.push('<a class="btn right icon-back" id="fightback" onclick="fightBack();"></a>');
        b.push("</div>");
        b.push('<div id="fightContent">');
        b.push('<ul class="otherside teamside" data-team="', n[0].team, '">');
        for (var e = 0; e < (n.length < 4 ? n.length: 4); e++) {
            var d = parseInt(n[e].effqixue, 10) / parseInt(n[e].maxqixue, 10) * 100;
            d = d == "NaN" ? 0 : Math.floor(d);
            var l = parseInt(n[e].qixue, 10) / parseInt(n[e].maxqixue, 10) * 100;
            l = l == "NaN" ? 0 : Math.floor(l);
            var a = parseInt(n[e].neili, 10) / parseInt(n[e].maxneili, 10) * 100;
            a = a == "NaN" ? 0 : Math.floor(a);
            a = a >= 100 ? 100 : a;
            b.push('<li data-uid="', n[e].id, '"  onclick="chooseEnemy(this);"><span class="membername">', n[e].name, "</span>");
            b.push('<span class="progressbox red" data-qixue="', n[e].qixue, '" data-effqixue="', n[e].effqixue, '"><span class="memberqixue">', n[e].qixue, '</span><span class="progress" style="width:', d, '%"></span>');
            b.push('<span class="progressshadow" style="width:', l, '%"></span><span class="progressbg"></span></span>');
            b.push('<span class="progressbox blue" data-neili="', n[e].maxneili, ' currentneili="', n[e].neili, '"><span class="progress" style="width:', a, '%"></span><span class="progressbg"></span></span>');
            b.push("</li>")
        }
        b.push("</ul>");
        b.push('<div class="fightmessage" id="fightmessage">');
        b.push('<ul id="fightmessageContent">');
        b.push("</ul>");
        b.push("</div>");
        b.push('<ul class="ourside teamside" data-team="', k[0].team, '">');
        for (e = 0; e < (k.length < 4 ? k.length: 4); e++) {
            b.push('<li data-uid="', k[e].id, '"><span class="membername">', k[e].name, "</span>");
            d = parseInt(k[e].effqixue, 10) / parseInt(k[e].maxqixue, 10) * 100;
            d = d == "NaN" ? 0 : Math.floor(d);
            l = parseInt(k[e].qixue, 10) / parseInt(k[e].maxqixue, 10) * 100;
            l = l = "NaN" ? 0 : Math.floor(l);
            a = parseInt(k[e].neili, 10) / parseInt(k[e].maxneili, 10) * 100;
            a = a == "NaN" ? 0 : Math.floor(a);
            a = a >= 100 ? 100 : a;
            b.push('<span class="progressbox red" data-qixue="', k[e].qixue, '" data-effqixue="', k[e].effqixue, '"><span class="memberqixue">', k[e].qixue, '</span><span class="progress" style="width:', d, '%"></span>');
            b.push('<span class="progressshadow" style="width:', l, '%"></span><span class="progressbg"></span></span>');
            b.push('<span class="progressbox blue" data-neili="', k[e].maxneili, ' currentneili="', k[e].neili, '"><span class="progress" style="width:', a, '%"></span><span class="progressbg"></span></span>');
            b.push("</li>")
        }
        b.push("</ul>");
        b.push('<ul class="fightbuttons"></ul>');
        b.push("</div>");
        b.push("</div>");
        $("body").append(b.join(""));
        $(".dialog").hide();
        $("#fightmessage").mCustomScrollbar({
            axis: "y",
            mouseWheel: {
                enable: true
            },
            advanced: {
                updateOnContentResize: true
            }
        });
        $("#fightPage").show();
        send("listpfmset")
    } else {
        for (var g = 0; g < f.startfight.length; g++) {
            var h = $("#fightContent").find('ul[data-team="' + f.startfight[g].team + '"]');
            var m = h.find('li[data-uid="' + f.startfight[g].id + '"]');
            if (h.find("li").length >= 4) {
                continue
            }
            if (m.length > 0) {
                console.log("该id已存在")
            } else {
                var c = [];
                var d = parseInt(f.startfight[g].effqixue, 10) / parseInt(f.startfight[g].maxqixue, 10) * 100;
                d = d == "NaN" ? 0 : Math.floor(d);
                var l = parseInt(f.startfight[g].qixue, 10) / parseInt(f.startfight[g].maxqixue, 10) * 100;
                l = l == "NaN" ? 0 : Math.floor(l);
                var a = parseInt(f.startfight[g].neili, 10) / parseInt(f.startfight[g].maxneili, 10) * 100;
                a = a == "NaN" ? 0 : Math.floor(a);
                a = a >= 100 ? 100 : a;
                if (h.attr("class") == "otherside teamside") {
                    c.push('<li data-uid="', f.startfight[g].id, '" onclick="chooseEnemy(this);">')
                } else {
                    c.push('<li data-uid="', f.startfight[g].id, '">')
                }
                c.push('<span class="membername">', f.startfight[g].name, "</span>");
                c.push('<span class="progressbox red" data-qixue="', f.startfight[g].qixue, '" data-effqixue="', f.startfight[g].effqixue, '"><span class="memberqixue">', f.startfight[g].qixue, '</span><span class="progress" style="width:', d, '%"></span>');
                c.push('<span class="progressshadow" style="width:', l, '%"></span><span class="progressbg"></span></span>');
                c.push('<span class="progressbox blue" data-neili="', f.startfight[g].maxneili, ' currentneili="', f.startfight[g].neili, '"><span class="progress" style="width:', a, '%"></span><span class="progressbg"></span></span>');
                c.push("</li>");
                h.append(c.join(""));
                continue
            }
        }
    }
}
function showJoinFight(e) {
    var c = [];
    var g = e.joinfight;
    var d = $("#fightContent").find('ul[data-team="' + g.team + '"]');
    var b = d.find('li[data-uid="' + g.id + '"]');
    if (b.length > 0) {
        return
    }
    if (d.find("li").length >= 4) {
        return
    }
    var f = parseInt(g.effqixue, 10) / parseInt(g.maxqixue, 10) * 100;
    f = f == "NaN" ? 0 : Math.floor(f);
    var a = parseInt(g.qixue, 10) / parseInt(g.maxqixue, 10) * 100;
    a = a == "NaN" ? 0 : Math.floor(a);
    var h = parseInt(g.neili, 10) / parseInt(g.maxneili, 10) * 100;
    h = h == "NaN" ? 0 : Math.floor(h);
    h = h >= 100 ? 100 : h;
    if (d.attr("class") == "otherside teamside") {
        c.push('<li data-uid="', g.id, '" onclick="chooseEnemy(this);">')
    } else {
        c.push('<li data-uid="', g.id, '">')
    }
    c.push('<span class="membername">', g.name, "</span>");
    c.push('<span class="progressbox red" data-qixue="', g.qixue, '" data-effqixue="', g.effqixue, '"><span class="memberqixue">', g.qixue, '</span><span class="progress" style="width:', f, '%"></span>');
    c.push('<span class="progressshadow" style="width:', a, '%"></span><span class="progressbg"></span></span>');
    c.push('<span class="progressbox blue" data-neili="', g.maxneili, ' currentneili="', g.neili, '"><span class="progress" style="width:', h, '%"></span><span class="progressbg"></span></span>');
    c.push("</li>");
    d.append(c.join(""))
}
function chooseEnemy(b) {
    var a = $(b).data("uid");
    $(".teamside li").removeAttr("style");
    $(b).attr("style", "border: 1px solid red");
    $('.fightbuttons li[data-direct^="perform"]').each(function() {
        $(this).data("id", a)
    })
}
function loadFightMessage(f) {
    if ($("#fightPage").length == 0) {
        send("checkfight");
        return
    }
    var h = f.fight;
    var a = h.msg;
    var g = a.split("|");
    var d = [];
    var b = f.fromname;
    var c = f.fromid;
    var l = f.toname;
    var k = f.toid;
    for (var e = 0; e < g.length; e++) {
        if (g[e].length > 3) {
            d.push("<li>", g[e], "</li>")
        }
    }
    var j = $("#fightmessageContent").find("li");
    if (j.length > 800) {
        for (var e = 0; e <= 100; e++) {
            j.eq(e).remove()
        }
    }
    $("#fightmessageContent").append(d.join(""));
    $("#fightmessage").mCustomScrollbar("scrollTo", "bottom");
    var c = h.fromid;
    addQixue(c, h.fromqixue, 1);
    addQixue(c, h.fromeffqixue, 2);
    $('li[data-uid="' + c + '"]').find(".memberqixue").html(h.fromqixue);
    addQixue(c, h.fromneili, 3);
    var k = h.toid;
    if (h.toqixue <= 0 && $('li[data-uid="' + k + '"]').attr("style") != "undefined") {
        $('li[data-uid="' + k + '"]').removeAttr("style");
        $('.fightbuttons li[data-direct^="perform"]').each(function() {
            $(this).removeAttr("data-id")
        })
    }
    addQixue(k, h.toqixue, 1);
    addQixue(k, h.toeffqixue, 2);
    $('li[data-uid="' + k + '"]').find(".memberqixue").html(h.toqixue);
    addQixue(k, h.toneili, 3)
}
function showFightData(b) {
    var a = "<li>" + b + "</li>";
    $("#fightmessageContent").append(a);
    $("#fightmessage").mCustomScrollbar("scrollTo", "bottom")
}
function addQixue(h, f, c) {
    var e = $('li[data-uid="' + h + '"]');
    if (c == 1) {
        var d = e.find(".red").data("qixue");
        var b = parseInt(f, 10) / parseInt(d, 10) * 100;
        b = b == "NaN" ? 0 : Math.floor(b);
        b = f <= 0 ? 0 : b;
        b = b >= 100 ? 100 : b;
        e.find(".red .progress").width(b + "%");
        var a = $('li[data-uid="' + h + '"]').find(".memberqixue").text();
        var g = f - parseInt(a, 10);
        g = !!g ? g: 0;
        if (g == 0) {
            return
        }
        g = g > 0 ? "+" + g: g;
        e.append('<span class="addRed show">' + g + "</span>")
    } else {
        if (c == 2) {
            var d = e.find(".red").data("effqixue");
            var b = parseInt(f, 10) / parseInt(d, 10) * 100;
            b = b == "NaN" ? 0 : Math.floor(b);
            b = f <= 0 ? 0 : b;
            e.find(".red .progressshadow").width(b + "%")
        } else {
            if (c == 3) {
                var d = e.find(".blue").data("neili");
                var b = parseInt(f, 10) / parseInt(d, 10) * 100;
                b = b == "NaN" ? 0 : Math.floor(b);
                b = b >= 100 ? 100 : b;
                b = f <= 0 ? 0 : b;
                e.find(".blue .progress").width(b + "%");
                var a = e.find(".blue").attr("currentneili");
                e.find(".blue").attr("currentneili", f);
                var g = f - parseInt(a, 10);
                g = !!g ? g: 0;
                if (g == 0) {
                    return
                }
                g = g > 0 ? "+" + g: g;
                e.append('<span class="addBlue showblue">' + g + "</span>")
            }
        }
    }
}
function showEndFightTip(c) {
    showFightData(c.msg);
    var a = c.subtype == "win" ? "胜利！": "失败！";
    var b = [];
    b.push('<li class="fightresulttitle">战斗结束</li>');
    if (isKilling && c.subtype == "win") {
        isKilling = false
    }
    $("#fightmessageContent").append(b.join(""));
    $("#fightback").show();
    setTimeout(function() {
        $("#fightmessage").mCustomScrollbar("scrollTo", "bottom")
    },
    200)
}
function clickFightBtn(c) {
    var b = $(c).data("direct");
    if ( !! b) {
        var a = $(c).data("npcid");
        send(b + " " + a)
    }
}
function decode(a) {
    var b = document.createElement("div");
    b.innerHTML = a;
    a = b.innerText || b.textContent;
    b = null;
    return a
}
function resize() {
    if ($(window).height() <= $(window).width()) {
        $("#page1").width($(window).height() * 0.563);
        $("#dialog").width($(window).height() * 0.563);
        $("#fightPage").width($(window).height() * 0.563)
    }
}
function intMax(b) {
    var a;
    a = parseInt($(b).val(), 10);
    if (isNaN(a)) {
        a = 0
    } else {
        if (a > $(b).attr("max")) {
            a = $(b).attr("max")
        }
    }
    $(b).val(a)
}

function showVipshop(){
	sendData("shop");
}




var GB2312UnicodeConverter={
  ToUnicode:function(str){
    return escape(str).toLocaleLowerCase().replace(/%u/gi,'\\u');
  }
  ,ToGB2312:function(str){
    return unescape(str.replace(/\\u/gi,'%u'));
  }
};



function addRoomObject(e){
	//动态插入的li获取不到父类的高度
	var f = $("#roomOtherInner").height();
	f = f * 25 / 100;
	f = f+"px";
	
	
	var s = '<li data-cmd="'+e.objectFile+'" data-text="'+ansi_up.ansi_to_text(e.objectTitle)+'" data-id="'+e.objectFile+'"  onclick="clickRoomObject(this);"><span>'+ansi_up.ansi_to_html(e.objectTitle)+'</span></li>';
	
	//style="min-height:'+f+';"
	$("#roomList").append(s);
	
	$("#roomList").find("li").each(function(){
		
		

		var li = $(this);
		var txt = li.attr("data-text");
		if( txt.length > 4 ){
	
			$(this).css("line-height","");
			$(this).css("min-height","");
		}else{
			$(this).css("line-height",f);
			$(this).css("min-height",f);
		}
			
	});

}

function clickRoomObject(c) {
    var a = $(c);
   	sendData(a.attr("data-cmd"));
}


/**
 * 工具类
 * by mike Q184377367
 */
var Utils = function(){};

Utils.prototype={
	
	filter:function(a,func){
		var l={};
		for(var e in a){
			if( func(e) ){
				l[e]=a[e];
				return l;
			}
		}
		return l;
	}
};

var utils = new Utils();


/**
 * 地图显示组件
 */
var ContentMapObject = function(){};

ContentMapObject.prototype={
	//容器
	container:null,
	//内部显示控件
	inner:null,
	//关闭图标
	closeIcon:null,
	create:function(e){
		this.container = e;
		this.inner = this.container.find("#inner");
		this.container.css({
			"overflow":"auto",
			"left":"16%",
			"height":"60%",
			"width":"81.5%",
			"border":"4px solid #000",
			"background":"#1F1F1F",
			"z-index":"999",
		});
		
		this.inner.css({
			"width":"200%",
		});
		
		this.container.mCustomScrollbar({
	        axis: "xy",
	        theme: 'dark',
	        mouseWheel: {
	            enable: true
	        },
	        advanced: {
	            updateOnContentResize: true
	        }
   		});
   		this.createCloseIcon();
   		this.doHide();
	},
	
	createCloseIcon:function(){
		var me = this;
		$("body").append('<div id="content-close-icon-map" style="position:absolute;background: #756565;color:#fff;left:92%;z-index:2000;top:12%;width:1.8em;height:1.8em;line-height:1.8em;text-align: center;">X</div>');
		me.closeIcon = $("#content-close-icon-map");
		me.closeIcon.on("click",function(){
			me.doHide();
		});
	},
	
	doHideCloseIcon:function(){
		this.closeIcon.hide();
		return this;
	},
	doShowCloseIcon:function(){
		this.closeIcon.show();
		return this;
	},
	
	setContent:function(txt){
		this.inner.html(txt);
		return this;
	},
	doHide:function(){
		this.inner.html("");
		this.doHideCloseIcon();
		this.container.hide();
	},
	doShow:function(){
		this.doShowCloseIcon();
		this.container.show();
	}
};
/**
 * 内容组件
 * by mike@Q184377367
 */

var ContentObject = function(){};

ContentObject.prototype={
	
	leftButBox:false,//左边按钮
	rightButBox:false,//右边按钮
	rightButBoxWidth:0,//右边整体宽度
	rightButWidth:0,//右边按钮宽度
	rightButHeight:1,//默认右边列的高度
	rightButList:0,
	rightButColNember:2,//默认1列
	leftButList:0,
	title:"",//标题
	firstElement:"",//前面隐藏的对象，当关闭ConTent时显示firstObject
	firsteo:0,
	label:"",//框中的标题
	contents:"",//框中的文字内容
	contentsBox:null,//弹出层
	contentTextBox:null,
	rightButStyle:0,
	leftButStyle:0,
	butsBox:null,//按钮容器
	isShow:false,
	headButBox:null,
	type:1,//默认为常规 2为输入框类型
	inputCmd:"", //type为2时 该值必须有 
	
	setIsShow:function(b){
		this.isShow = b;
	},
	//是否已显示
	getIsShow:function(){
		return this.isShow;
	},
	
	
	setRightButStyle:function(e){
		this.rightButStyle = e;
		return this;
	},
	
	setLeftButStyle:function(e){
		this.leftButStyle = e;
		return this;
	},
	
	setFirstElement:function(e){
		this.firstElement = e;
		return this;
	},
	
	
	renderLeftButList:function(){
		var str = "";
		
		if (this.leftButList==0 || this.leftButList.length<=0){
			
			this.leftButBox.find("#leftButList").html("");
			return;
		}
		
		
		var d = this.leftButList;
		for(var e in d){
			str+="<li data-cmd='"+d[e].cmd+"' style='width:100%'>"+d[e].label+"</li>";
		}
		this.leftButBox.find("#leftButList").html("");
		this.leftButBox.find("#leftButList").html(str);
	},
	
	setLeftButList:function(d){
		this.leftButList = d;
		return this;
	},
	
	renderRightButList:function(){
		
		var str = "";
		if (this.rightButList==0 || this.rightButList.length<=0){
			this.rightButBox.find("#rightButList").html("");
			return;
		}
		
		var d = this.rightButList;
		
		for(var e in d){
			str+="<li data-cmd='"+d[e].cmd+"' style='width:"+this.rightButWidth+"%'>"+ansi_up.ansi_to_html(d[e].label)+"</li>";
		}
		this.rightButBox.find("#rightButList").html("");
		this.rightButBox.find("#rightButList").append(str);
	},
	
	setRightButList:function(d){
		this.rightButList = d;
		return this;
	},
	
	setContents:function(s){
		this.contents = s;
		return this;
	},
	
	setHeadButs:function(d){
		
		var str,ele;
		var hbt = $("#head-but-content-list");
		hbt.html("");
		for(var e in d){
			
			str = "<li data-cmd="+d[e].cmd+">"+d[e].label+"</li>";
			ele = $(str);
			ele.on("click",function(){
				sendData($(this).attr("data-cmd"));
			});
			hbt.append(ele);
		}
		
	},
	
	/**
	 * 设置内容框的类型
	 * @param {Object} t
	 */
	setContentBoxType:function(t){
		this.type = t;
		return this;
	},
	
	/**
	 * 当作为输入容器时，必须设定输入框区域按钮点击后发送的指令
	 * @param {Object} c
	 */
	setInputCmd:function(c){
		var me = this;
		this.inputCmd = c;
		
	
		
		this.inputAreaBut.on("click",function(){
			
			var txt = me.inputAreaTextarea.val();
			txt = me.inputCmd.replace(/\$txt#/g,txt);
			netHelper.send(txt);
			me.cleanData().doHide();
			
		});
		return this;
	},
	//渲染
	render:function(){
		var me = this;
		this.initWHParam();
		this.renderLeftButList();
		this.renderRightButList();
		this.contentTextBox.find(".descinners").html(this.contents);
		
		this.rightButBox.find("li").each(function(){
   	 		$(this).on("click",function(){
   	 			sendData($(this).attr("data-cmd"));
   	 			me.cleanData().doHide();
   	 		});
   	 	});
   	 	
   	 	
   	 	this.leftButBox.find("li").each(function(){
   	 		$(this).on("click",function(){
   	 			sendData($(this).attr("data-cmd"));
   	 			me.cleanData().doHide();
   	 		});
   	 	});
   	 	
   	 	
   	 	
   	 	
   	 	return this;
   	 	
	},
	
	delete:function(){
		this.contentsBox.remove();
		this.firsteo.show();
		this.leftButList = 0;
		this.rightButList =0 ;
	},
	//没有按钮组?
	isNoneBut:function(){
		if((this.rightButList==0 || this.rightButList.length<=0) && ( this.leftButList==0 || this.leftButList.length<=0) ){
			return true;
		}
		return false;
	},
	
	//初始化各子控件大小
	initWHParam:function(){
		
		var me = this;
		//console.log(this.leftButList.length);
		
		if(this.contents==""){//没有文本内容
			//this.contentsBox.hide();
			//this.rightButBox.css({"height":"100%"});
			//this.leftButBox.css({"height":"100%"});
		}else{
			//this.contentsBox.show();
			
		//	this.rightButBox.css({"height":"50%"});
			//this.leftButBox.css({"height":"50%"});
		}
		
		
		if(this.leftButList==0 || this.leftButList.length<=0){
		
			this.leftButBox.hide();
			this.rightButBox.css({"width":"100%"});
		}else{
			this.leftButBox.show();
			this.rightButBox.css({"width":"80%"});
		}
	
		if(this.rightButList==0 || this.rightButList.length<=0){
			this.rightButBox.hide();
		}else{
			this.rightButBox.show();
		}
		
		//如果完全没有按钮
		/*
		if(this.isNoneBut()){
			this.contentTextBox.css({"height":"80%"});
			this.contentTextBox.css({"max-height":"100%"});
		}else{
			this.contentTextBox.css({"height":"3%"});
			this.contentTextBox.css({"max-height":"40%"});
		}*/
		
		//this.contentTextBox.css({"height":"3%"});
		if(this.rightButStyle!=0){
			this.rightButColNember = this.rightButStyle.colNumber;
		}
		
		
		
		
		//获取宽度
		this.rightButBoxWidth = this.rightButBox.css("width").split("px")[0];
		//右边按钮宽度
		this.rightButWidth = this.rightButBoxWidth / this.rightButColNember;
		//百分比
		this.rightButWidth = (this.rightButWidth / this.rightButBoxWidth) * 100;
		//防止宽度变形 只取百分之80
		this.rightButWidth = this.rightButWidth * 90 /100;
		
		//调整输入框的按钮大小
		var h = this.inputAreaTextarea.css("height");
		
		//h = (h + 20)+"px";
		this.inputAreaBut.css({"height":h});
	
	
		this.leftButBox.mCustomScrollbar({
	        axis: "y",
	        theme: 'minimal-dark',
	        mouseWheel: {
	            enable: true
	        },
	        advanced: {
	            updateOnContentResize: true
	        }
   		 });
   	 
   	 	this.rightButBox.mCustomScrollbar({
	        axis: "y",
	        theme: 'minimal-dark',
	        mouseWheel: {
	            enable: true
	        },
	        advanced: {
	            updateOnContentResize: true
	        }
   	 	});
   	 	
   	 	this.contentsBox.mCustomScrollbar({
	        axis: "y",
	        theme: 'minimal-dark',
	        mouseWheel: {
	            enable: true
	        },
	        advanced: {
	            updateOnContentResize: true,
	           //autoExpandHorizontalScroll:true,
	        },
	        
	        callbacks:{
		      onScrollStart: function(){
		      	//console.log(me.contentsBox.find("#mCSB_8_container").css("height","2500px"));
		      
		      },
	        onScroll:function(){
		      console.log("Content scrolled...");
		    }
			},
   	 	});
	
		/*
	   	 	$(".head-but-content").mCustomScrollbar({
		        axis: "x",
		        theme: 'minimal-dark',
		        scrollButtons:{ 
		        	enable:true,
		        	scrollAmount:40
		        },
		        mouseWheel: {
		            enable: true
		        },
		        advanced: {
		            updateOnContentResize: true
		        }
   	 	});*/
		

			
		
	},
	
	/**
	 * 创建容器 只有一个实例
	 * 创建之后只能通过doHide doShow 显示和隐藏
	 * @param {Object} e
	 */
	create:function(e){
		
		var me = this;
		this.firstElement = e;
		
		if(this.contentsBox!=null){
			this.delete();
		}
		
		//先输出框架代码
		var strVar = "";
	    strVar += "<div class=\"content\" data-role=\"contentBox\" style=\"left:16%;height:70%;	width:81.5%;border: 4px solid #000;background: #1F1F1F;display:none;z-index:999;\">\n";

		//strVar += "	    			<div  style='left:40%;top:5%;position: absolute;'><span id='close' style='font-size:1.2em;'>X</span></div>";
	  
	 


	  	strVar += "	    			<div class=\"desc\" style='height:8%;padding-top:5%;'>\n";
	  	//strVar += "	    			<div class=\"desc\" >\n";
	    strVar += "	    				<div class=\"descinners\">";
	   
	
	    strVar += "	    				<\/div>";
	    strVar += "	    			<\/div>";
	    
	    strVar +="<div id='inputArea' style='display:none;text-align:center;width:90%;height:20%;padding-left:5%;padding-top:5%;'>";
	    
	    strVar +="<div style='width:80%;height:100%;float:left;'>";
	    strVar +="<textarea style='width:93%;height:100%;'></textarea>";
	    strVar +="</div>";
	    
	   	strVar +="<div style='float:left;width:15%;height:100%;'>";
	    strVar +="<input style='background:rgba(0,0,0,0.5); border:none;color:#fff;width:100%;height:100%;' type='submit' value='确定'>";
	    strVar +="</div>";
	    strVar +="</div>";
	    
	    
	    
	    strVar += "	    			<!--按钮块-->\n";
	    strVar += "	    			<div id=\"buts\">\n";
	
	    strVar += "		    			<div id=\"leftBut\">\n";
	    strVar += "		    				<ul id=\"leftButList\">\n";
		strVar += "		    				<\/ul>\n";
	    strVar += "		    			<\/div>\n";

	    strVar += "		    			<div id=\"rightBut\">\n";
	    strVar += "		    				\n";
	    strVar += "		    				<ul id=\"rightButList\">\n";

	    strVar += "		    				<\/ul>\n";
		
	    strVar += "		    			<\/div>\n";
		strVar += "<p>&nbsp;<br>";
	    strVar += "	    			<\/div>\n";
		
	    strVar += "	    			<\/div>\n";
	    
	  
		//更新标题
		$("#title").html(this.title);
		
		$("#content").append(strVar);
		
		
		//原始隐藏
		$("."+this.firstElement).each(function(){
			if( $(this).attr("data-role")=="main" ){
				me.firsteo = $(this);
				//me.firsteo.hide();
			}
			
			if( $(this).attr("data-role")=="contentBox" ){
				me.contentsBox = $(this);
			}
			
			
		});
		
		
		this.contentTextBox = this.contentsBox.find(".desc");
		//绑定对象
		this.butsBox 		= $("#buts");
		this.leftButBox 	= $("#leftBut");
		this.rightButBox 	= $("#rightBut");
		this.headButBox 	= $("#head-but-content-list");
		//输入区域
		this.inputArea 		= $("#inputArea");
		this.inputAreaTextarea 	= this.inputArea.find("textarea");
		this.inputAreaBut 		= this.inputArea.find("input");
		
		
		//调整关闭按钮位置
		return this;
		
	},
	createCloseIcon:function(){
		var me = this;
		$("body").append('<div id="content-close-icon" style="position:absolute;background: #756565;color:#fff;left:92%;z-index:2000;top:12%;width:1.8em;height:1.8em;line-height:1.8em;text-align: center;">X</div>');
		$("#content-close-icon").on("click",function(){
			$(this).remove();
			me.cleanData().doHide();
		});
	},
	doShow:function(){
		
		this.createCloseIcon();
		this.isShow = true;
		this.contentsBox.show();
		if(this.type==2){
			this.inputArea.show();
		}
		
	
	},
	doHide:function(){
		$("#content-close-icon").remove();
		this.isShow = false;
		this.contentsBox.hide();
		if(this.type==2){
			this.inputArea.hide();
		}
		
	},
	/***
	 *清空所有数据
	 */
	cleanData:function(){
		this.leftButList = [];
		this.rightButList = [];
		this.inputAreaTextarea.val("");
		this.inputCmd="";
		
		return this;
	},
	
	
	//分析文字内容
	analysisContents:function(){
		
	}
	
};



/*
 * 游戏实例类
 * by mike@Q184377367
 * */
var GameCore = function(){};



GameCore.prototype={
	longBoxRButParam : {},
	longBoxLButParam : {},
	contentBox:null,
	
	funcButtonPanl:null, //$("#funcButtonPanl");
	exitsPanl:null, //= $("#exitsPanl");
	
	
	//各种出口
	superExits : {
					"northwest"	:"northwest",
					"north"		:"north",
					"northeast"	:"northeast",
					"west"		:"west",
					"east"		:"east",
					"southwest"	:"southwest",
					"south"		:"south",
					"southeast"	:"southeast",
					
					//2.5D方向
					"northup"	:"north",
					"northdown"	:"north",
					"southup"	:"south",
					"southdown"	:"south",
					"eastdown"	:"east",
					"eastup"	:"east",
					"westdown"	:"west",
					"westup"	:"west",
					
					"northeastup"	:"northeast",
					"northeastdown"	:"northeast",
					
					"northwestup"	:"northwest",
					"northwestdown"	:"northwest",
					
					"southeastup"	:"southeast",
					"southeastdown"	:"southeast",
					
					"southwestup"	:"southwest",
					"southwestdown"	:"southwest",
	},
	
	//出口记录
	exitsDict : {
					"e1":["northwest","northwestup","northwestdown"],
					"e2":["north","northup","northdown"],
					"e3":["northeast","northeastup","northeastdown"],
					"e4":["west","westdown","westup"],
					"e5":["east","eastdown","eastup"],
					"e6":["southwest","southwestup","southwestdown"],
					"e7":["south","southup","southdown"],
					"e8":["southeast","southeastup","southeastdown"],
				
	},
	
	setContentBox:function(e){
		this.contentBox = e;
	},
	
	//判断是否是其他出口,
	isOtherExit:function(ex){
		 var a=[],x;
		 utils.filter(this.exitsDict,(n)=>{
		 		 $.merge(a, this.exitsDict[n]);      
	     });
	     if($.inArray(ex,a) < 0){
	     	return true;//是其他出口
	     }
	     return false;
	    	
	},

	//根据VAL获取出口字电KEY
	getExitsDictKeyByVal:function(v){
		var f,x;
		 f = utils.filter(this.exitsDict,(n)=>{
				if( $.inArray(v,this.exitsDict[n]) < 0 ) return false;
					return true;
	    });
	    
    	utils.filter(f,(e)=>{
    		x = e;
    	});
    	return x;
	},


	init:function(){
		
		this.funcButtonPanl = $("#funcButtonPanl");
		this.exitsPanl 		= $("#exitsPanl");
		
		
		this.bindEvtToele();
		
	},
	bindEvtToele:function(){
		
		var me = this;
		 $("#back").click(function() {
	        isFromItem = false;
	        isFromNpc = false;
	        isFromPlayer = false;
	        isFromMe = false;
        
      
        
        
       me.contentBox.doHide();
    
        
        var c = titles.length - 1;
        titles.splice(c, 1);
        var b = titles[titles.length - 1];
        if (b == "状态") {
            $(".statuslist li.active").trigger("click")
        }
        $("#title").html(titles[titles.length - 1]);
        //$(".content").last().show()
        $(".content[data-role='main']").show();
    });
    
    $("#nav-rightbtn").off("click").on("click",function() {
    	sendData("map area");
    });
    
    

  
    
    $("body").on("click", ".chatperson",function() {
        $("#friendbox").removeClass("active");
        var c = $(this).data("uid");
        var a = $(this).html();
        var b = {
            id: c,
            name: a
        };
        if (c == "0") {
            return
        }
        $(".sendbox .personbox").html(a).data("uid", c);
        storageFriend(b);
        refreshFriend();
        $("#messageinner").mCustomScrollbar("scrollTo", "bottom")
    });
		
		
		
     $("#roomInner").mCustomScrollbar({
        axis: "y",
        　	theme: 'minimal-dark',
         mouseWheel: {
            enable: true
        },
		advanced: {
            updateOnContentResize: true
        },
		
    });
    
     $("#roomOtherInner").mCustomScrollbar({
        axis: "y",
        　	theme: 'minimal-dark',
         mouseWheel: {
            enable: true
        },
		advanced: {
            updateOnContentResize: true
        },
		
    });
    
     $("#chatInner").mCustomScrollbar({
        axis: "y",
        　	theme: 'minimal-dark',
         mouseWheel: {
            enable: true
        },
		advanced: {
            updateOnContentResize: true
        },
		
    });
    
    
    
    
    
    
     var a;
    
    $(".content").each(function(){
    	if($(this).attr("data-role")=="main"){
    		a = $(this).find(".desc");
		   	if(a.length>0){
			    a.mCustomScrollbar({
			        axis: "y",
			        mouseWheel: {
			            enable: true
			        },
			        advanced: {
			            updateOnContentResize: true
			        }
			    });
		    }
    		
    		
    		
    	}
    });
    
   
   
    
    
 
    $("#messageinner").mCustomScrollbar({
        axis: "y",
        theme: 'min',
        mouseWheel: {
            enable: true
        },
        advanced: {
            updateOnContentResize: true
        }
    });


        $(".message>.shrink").each(function(){
	
	
	    	$(this).on("click",function(){
	    		var role = $(this).attr("data-role");
	    		if(role=="shrinkAndExpandMessage"){
	    			
				    if ($(this).hasClass("active")) {
				        $(".page").addClass("shrink-message");
				        $(this).removeClass("active").html("展开")
				    } else {
				        $(".page").removeClass("shrink-message");
				        $(this).addClass("active").html("收起");
				    }
	    		}else{
	    			if($(this).html()=="功能"){
	    				$(this).addClass("active").html("聊天");
						$("#messageinner").removeClass("messageinner-ext-buts");
							var str="<li>基本属性</li>";
	    				str+="<li>状态属性</li>";
	    				str+="<li>状态属性</li>";
	    				str+="<li>状态属性</li>";
	    				$("#messageinner").find("ul").html(str);
	    				
	    			}else{
	    				
	    				$(this).addClass("active").html("功能");
	    				
	    				var str="<li>基本属性</li>";
	    				str+="<li>状态属性</li>";
	    				$("#messageinner").find("ul").html(str);
	    				
	    				$("#messageinner").addClass("messageinner-ext-buts");
	    			}
	    			
	    		}
	    	});
	    	
	    });
		    
	    //九方向点击事件绑定
	    $(".direction-item div").each(function(){
	    	$(this).on("click",function(){
	    		sendData($(this).attr("data-exit"));
	    	});
	    });
	    
		//三个按钮
		$("#swapButs").on("click",function(){
		
			var show = me.funcButtonPanl.css("display");
			if(show=="block"){
				me.funcButtonPanl.hide();
				me.exitsPanl.show();
			}else{
				me.funcButtonPanl.show();
				me.exitsPanl.hide();	
			}
		});
		
		$("#mapButs").on("click",function(){
			
			netHelper.send("map view");
			 
		});
		

		
		
		
	},
	onExitClick:function(e){
		var exit = $(e).attr("data-exit");
		
		sendData(exit);
	},
	
	removeExits:function (b) {
	    var c = b.exits;
	    if ( !! c) {
	        var a = $(".ditection #" + c);
	        if (a.length > 0) {
	            $("#" + c).html("").removeClass("active")
	        }
	    }
	},
	//删除指定出口
	removeByExitId:function(b) {
		
		//判断出口类型
		
    	
    	if( this.isOtherExit(b) ){
    		
    		$(".otherdirects #otherDir li").each(function(){
    			if($(this).prop("id")==b){
    				$(this).remove();
    			}
    		});
				
    		
    	}else{
    		var a = $(".ditection #" + this.getExitsDictKeyByVal(b));
    		//找出KEY
    		
       		a.html("").removeClass("active");
    	}
    	
		
   		
	},
	
	
	//添加出口
	addExits:function(d){
		//003east:东练功房$zj#west:后院$zj#south:南练功房
		
		var e,f,t,text;
		var str;
		
    	for(var exits in d){
    		
    		
    		
    		
    		t = ansi_up.ansi_to_html(d[exits]);
    		text = ansi_up.ansi_to_text(d[exits]);
			if( this.isOtherExit(exits)  ){
				
				f = $("#roomOtherInner").height();
				f = f * 25 / 100;
				f = f+"px";
				str = "<li id='"+exits+"' data-text='"+text+"' data-exit='"+exits+"' onClick='gcr.onExitClick(this)'";
				//str+="class='room-other-item' style='height:"+f+";line-height:"+f+";'>"+t+"</li>";
				//str+="class='room-other-item'>"+t+"</li>";
				str+="class='room-other-item'>"+t+"</li>";
				
				$("#roomOtherList").append(str);
				$("#roomOtherList").find("li").each(function(){
						
						
						var txt = $(this).attr("data-text");
						if( txt.length > 4 ){
					
							$(this).css("line-height","");
							$(this).css("min-height","");
						}else{
							$(this).css("line-height",f);
							$(this).css("min-height",f);
						}
				});
				
			}else{
				
	    		e = $(".ditection").find("#"+this.getExitsDictKeyByVal(exits));
				e.addClass("active").html( t ).attr("data-exit",exits);
				
			}
				
    	}
		
	},
	//滚动通知
	showNotification:function (e) {
		var me = this;
	    if ( !! e) {
	        var a = $("#notification");
	        if (a.children(":first").is(":animated")) {
	            noticeList.push(e)
	        }
	        if (a.length == 0) {
	            $("body").append('<div id="notification"><span></span></div>');
	            a = $("#notification")
	        }
	        a.children(":first").html(e);
	        a.show();
	        var d, c, b;
	        c = a.width();
	        b = a.children(":first").width();
	        a.children(":first").css("left", c);
	        if (b > 0) {
	            d = (c + b) * 1000 / 48;
	            a.children(":first").animate({
	                left: 0 - b
	            },
	            d,
	            function() {
	                if (noticeList.length == 0) {
	                    $(this).parent().hide();
	                } else {
	                    var f = noticeList[0];
	                    noticeList.shift();
	                    me.showNotification(f);
	                }
	            })
	        }
	    }
	},
	showQuests:function() {
	   
		sendData("mycmds quest");

  	},
  	
  	showSkills:function() {
  		
		sendData("mycmds skill");
  	},
  	showStatus:function() {
  		
	   sendData("mycmds ofen");
  	
  	},
  	showChat:function(){
  		sendData("liaotian");

  	},
  	
  	
  	showUserButs:function(d){
  		
  		var str="",cmd,i=1;
  		
  		for(var e in d){
  			str+="<li data-cmd='"+d[e].cmd+"'>"+d[e].label+"</li>";
  			i++;
  			if(i>10) break;
  		}
  		
  		$("#funcButtonPanl ul").html("");
  		$("#funcButtonPanl ul").append(str);
  		
  		$("#funcButtonPanl li").each(function(){
  			$(this).on("click",function(){
  				cmd = $(this).attr("data-cmd");
  				netHelper.send(cmd);
  			});
  		});
  		
  		//显示一次面板
  		this.funcButtonPanl.show();
  		this.exitsPanl.hide();
  		
  		
  		
  	},


    onLoginBut:function(e){

        var a = $("#dialog"),
            username,
            password;

        username = a.find("input[id='username']").val();
        password = a.find("input[id='password']").val();
        sendData(username+","+password+",1,1");
        a.hide();
    },
    //显示登录界面
    showLoginDialog:function() {

        var c = [];
        c.push('<span style="margin-left: 5%;">账号：</span><input id="username" type="text" style="height:2em;margin-top: 2%;margin-left: 10%;"><br>');
        c.push('<span style="margin-left: 5%;">密码：</span><input id="password" type="text" style="height:2em;margin-top: 2%;margin-left: 10%;">');
        var a = $("#dialog");
        a.find(".dialog-title").html("登录<div class='clsDlgbtn'>X</div>");
        a.find(".dialog-content").html(c.join(""));
        var b=`<div class="dialogbtn"><a onclick="gcr.onLoginBut(this);">登录</a></div>
       <div class="dialogbtn"><a onclick="closeDialog();">取消</a></div>`;

        
        a.find(".dialog-buttons").html(b);
        a.show();

    },



    //显示注册角色界面
    showRegRoleDialog:function() {

        var c = [];
        c.push('<span style="margin-left: 5%;">账号：</span><input id="username" type="text" style="height:15%;margin-top: 2%;margin-left: 10%;"><br>');
        c.push('<span style="margin-left: 5%;">密码：</span><input id="password" type="text" style="height:15%;margin-top: 2%;margin-left: 10%;">');
        c.push('<span style="margin-left: 5%;">手机号：</span><input id="password" type="text" style="height:15%;margin-top: 2%;margin-left: 10%;">');
        var a = $("#dialog");
        a.find(".dialog-title").html("用户注册<div class='clsDlgbtn'>X</div>");
        a.find(".dialog-content").html(c.join(""));
        var b=`<div class="dialogbtn"><a onclick="gcr.onLoginBut(this);">注册</a></div>
       <div class="dialogbtn"><a onclick="closeDialog();">取消</a></div>`;
        a.find(".dialog-buttons").html(b);
        a.show();

    },




    //显示服务器界面
    showServerListDialog:function() {

        var c = [];
        c.push('<span style="margin-left: 5%;">账号：</span><input id="username" type="text" style="height:15%;margin-top: 2%;margin-left: 10%;"><br>');
        c.push('<span style="margin-left: 5%;">密码：</span><input id="password" type="text" style="height:15%;margin-top: 2%;margin-left: 10%;">');
        c.push('<span style="margin-left: 5%;">手机号：</span><input id="password" type="text" style="height:15%;margin-top: 2%;margin-left: 10%;">');
        var a = $("#dialog");
        a.find(".dialog-title").html("用户注册<div class='clsDlgbtn'>X</div>");
        a.find(".dialog-content").html(c.join(""));
        var b=`<div class="dialogbtn"><a onclick="gcr.onLoginBut(this);">注册</a></div>
       <div class="dialogbtn"><a onclick="closeDialog();">取消</a></div>`;
        a.find(".dialog-buttons").html(b);
        a.show();

    },







  	showHpStatus:function(d){
  	
  		var str="",
  			mw=0,
  			ew=0,
  			pw=0;
  		for(var e in d){
  			
  			
  			ew = (d[e].eff / d[e].max) * 100;
  			pw = (d[e].min / d[e].max) * 100;
  			
			str+='<div class="hp-progressbg">';
			str+='<div data-max="'+d[e].max+'" class="hp-progress-max">';
			str+='<div data-eff="'+d[e].eff+'" class="hp-progress-eff" style="width:'+ew+'%;">';
			
			str+='<div data-eff="'+d[e].min+'" class="hp-progress" style="background-color:'+d[e].color+';width:'+ew+'%;">';
			str+=d[e].txt+":"+d[e].min;
			str+='</div></div></div></div>';

  		}
  		$("#hpBox").html("");
  		$("#hpBox").append(str);

  		
  	},
	showFight:function(){
		sendData("mycmds fight");
	},
	
	showBag:function(){
		netHelper.send("i");
	},
	
	onRightFiexButsClick:function(e){
		var cmd = $(e).attr("data-cmd");
		netHelper.send(cmd);
	},
  	showRightFiexButs:function(d){
  		
		var str="",	topf = 19;
		for(var e in d){
			str+="<div onclick='gcr.onRightFiexButsClick(this);' data-cmd='"+d[e].cmd+"' class='right-flex-buts-d' style='top:"+topf+"%;'>"+d[e].label+"</div>";
			topf+=7;
		}
		
		$(str).insertAfter("#fwa-center");
	},
	onNetData:function(event){
		
		var dataOBject;
		
		if(confHelper.debug){
			console.log(event);
		}
		if( event.data=="100010" ){
			sendData("100010:"+confHelper.connectServer.ip+":"+confHelper.connectServer.port);
			return;
		}
		
	     if (event.data.indexOf("ver1.0")>=0){
          
            sendData("ZWUxMTIyMDAwMw==");

        }else if(event.data.indexOf("verifythrough")>=0){
 			// $("#loginDialog").find(".dialog-content").css("overflow", "visible");
			// $("#loginDialog").show();
             this.showLoginDialog();
        }
      
        dataOBject = reosval.takeMessage(event.data);
        if(dataOBject==null){
        	return;
        }
		
		if(dataOBject.type==ProtocolObjectType.channel){
        	
        	var str = ansi_up.ansi_to_html(dataOBject.text);
        	
        	showMainChatMessage(str);
        	return;
        }
		
      	if(dataOBject.type==ProtocolObjectType.oncmds){
        	sendData(dataOBject.cmd);
        	console.log(dataOBject);
        	return;
        }
      	if(dataOBject.type==ProtocolObjectType.roomDesc){
        	
        	$(".desc .descinner").html(ansi_up.ansi_to_html(dataOBject.text));
 			return;
        }
     	if(dataOBject.type==ProtocolObjectType.roomTitle){
     		//房间名发生变化。出口全部清除
        	removeAllExits();
        	//清除ROOM物件
        	$("#roomList").html("");
        	$("#roomOtherList").html("");
			$("#title").text(ansi_up.ansi_to_html(dataOBject.text));
        	
        	$(".ditection").find("#look").addClass("active").html(dataOBject.text);
        	return;
        }
     	
     
     	if(dataOBject.type==ProtocolObjectType.exits){
        	 
        	this.addExits(dataOBject.exits);
        	
        	return;
        	
        }
     	
     	if(dataOBject.type==ProtocolObjectType.hpInfo){
     		
     		this.showHpStatus(dataOBject.hp);
			return;
        }
     	
     	
     	if(dataOBject.type==ProtocolObjectType.roomObject){
     		
     		var a = dataOBject.objects;
     		for(var e in a){
				addRoomObject( a[e] );
			}
        }
     	
     	if(dataOBject.type==ProtocolObjectType.removeRoomObejct){
     		//找出对应的OBJECT
     		
     		
     		$("#roomList li").each(function(){
     			var objectId = $(this).attr("data-id");
     			if(dataOBject.objectId==objectId){
     				$(this).remove();
     			}
     			
     		});
     		
			return;
        }
     	
     	//删除对应出口
     	if(dataOBject.type==ProtocolObjectType.removeExit){
     		this.removeByExitId(dataOBject.exit);
  			return;
        }
     	         	

     	
     	if(dataOBject.type==ProtocolObjectType.longBoxRB){

     	
     		cts.setRightButList( dataOBject.rightButList );
			cts.setRightButStyle(dataOBject.butStyle);
			cts.render();
     		
     		return;
        }
     	
     	
     	if(dataOBject.type==ProtocolObjectType.longBoxLB){
     		
			cts.setLeftButList( dataOBject.leftButList );
			cts.setLeftButStyle(dataOBject.butStyle);
			cts.render();
     		return;
        }
     	
 	    if(dataOBject.type==ProtocolObjectType.openLongBox){
 		
 		
 	
	 		if( cts.getIsShow() ){
	 			cts.cleanData().doHide();
	 		}
 			var isTxt = dataOBject.contents=="" ? "" : ansi_up.ansi_to_html(dataOBject.contents);
     		cts.setContents( isTxt ).setContentBoxType(1);
     		cts.render().doShow();
     		return;
        }
     	
     	
     	
     	
     	
     	
     	if(dataOBject.type==ProtocolObjectType.notification){
     		//showWarnTip("xxxx");
     		//gcr.showNotification("<span style='color:#fff;'>"+dataOBject.text+"</span>");
     		return;
        }
     	
     	if(dataOBject.type==ProtocolObjectType.rightFiexButs){
     		this.showRightFiexButs(dataOBject.buts);
     		return;
        }
     
     	if(dataOBject.type==ProtocolObjectType.butsGrop){
     		this.showUserButs(dataOBject.buts);
     		return;
        }
     	
     	if(dataOBject.type==ProtocolObjectType.input){
     		if( cts.getIsShow() ){
	 			cts.cleanData().doHide();
	 		}
     		
     	//	console.log(dataOBject);
     		cts.setContents( dataOBject.text ).setInputCmd(dataOBject.cmd).setContentBoxType(2);
     		cts.render().doShow();
     		return;
        }
     	
     	
    	 if(dataOBject.type==ProtocolObjectType.map){
    	 	
    	 	if( cts.getIsShow() ){
	 			cts.cleanData().doHide();
	 		}
    	 	cmap.doHide();
    	 	dataOBject.text = ansi_up.ansi_to_html(dataOBject.text)
     		cmap.setContent(dataOBject.text).doShow();
     		return;
        }
     	
     	
     	
     	showMessage( ansi_up.ansi_to_html(dataOBject.text));
	}
	
	
};


/**
 *网络帮助类
 * by mike@QQ184377367
 */
var NetHelper=function(){};

NetHelper.prototype = {
	
	socket:null,
 	connect:function(s){
 		this.onCallBack.connectedBefore();
 		this.init();
 	},
 	onCallBack:{},
 	on:function(func,call){
 		this.onCallBack[func] = call;
 	},
 	
 	init:function(){
 		var me =this;
	    if(!window.WebSocket){
			window.WebSocket = window.MozWebSocket;
	    }
		this.socket = new WebSocket(confHelper.wockServer);
		//绑定事件
			
	    if(window.WebSocket){
	       	this.socket.onmessage = function(event){
	        	
			 	gcr.onNetData(event);
	        };
	
	        this.socket.onopen = function(event){
				var msg = "打开WebSoket 服务正常，浏览器支持WebSoket!"+"\r\n";
				me.onCallBack.connected();
				this.send("100009")
	            console.log(msg);
	
	        };
	
	        this.socket.onclose = function(event){
				var msg = "WebSocket 关闭"+"\r\n";
	           console.log(msg);
	        };
	    }else{
	        console.log("您的浏览器不支持WebSocket协议！");
	    }
 	},
 	send:function(message){
 		
 		console.log(message);
 		
 		if(this.socket.readyState == WebSocket.OPEN){
            this.socket.send(message);
        }else{
           console.log("WebSocket 连接没有建立成功！");
		}
	},
};


var ConfHelper = function(){};

ConfHelper.prototype={
	connectServer:{
		ip:"118.123.21.39",
		port:"7575",
	},
	wockServer:"ws://118.123.21.39:8081/websocket",
	debug:false,
};
var confHelper = new ConfHelper();

var netHelper = new NetHelper();


var reosval = new Reosval();

var gcr = new GameCore();

var cts = new ContentObject();

var cmap = new ContentMapObject();


function sendData(message) {
	netHelper.send(message);
}


window.onload = function() {

	gcr.init();
	cts.create("content");
	gcr.setContentBox( cts );
	
	cmap.create($("#mapbox"));
	
	netHelper.on("connected",function(){
		$("#loading").hide();
		$("#page1").show();
	});
	
	netHelper.on("connectedBefore",function(){
		$("#loading").show();
		$("#page1").hide();
	});
	
	netHelper.connect();
	
	

}


